diff --git a/.htaccess b/.htaccess index d6caa7bad..26694a893 100644 --- a/.htaccess +++ b/.htaccess @@ -1,351 +1,353 @@ # BEGIN Expires Don't forget to enable mod_headers and mod_expires, you can do so by running a2enmod rewrite and a2enmod headers ExpiresActive On ExpiresDefault "access plus 1 seconds" ExpiresByType text/html "access plus 1 seconds" ExpiresByType image/gif "access plus 2592000 seconds" ExpiresByType image/jpeg "access plus 2592000 seconds" ExpiresByType image/png "access plus 2592000 seconds" ExpiresByType text/css "access plus 604800 seconds" ExpiresByType text/javascript "access plus 216000 seconds" ExpiresByType application/x-javascript "access plus 216000 seconds" Order Allow,Deny Deny from all Require all denied Order Allow,Deny Deny from all Require all denied Order Allow,Deny Deny from all Require all denied Order Allow,Deny Deny from all Require all denied # Disable directory browsing Options All -Indexes # END Expires # BEGIN Caching Header set Access-Control-Allow-Origin: * Header set Cache-Control "max-age=2592000, public" Header set Cache-Control "max-age=604800, public" Header set Cache-Control "max-age=216000, private" Header set Cache-Control "max-age=216000, public, must-revalidate" Header set Cache-Control "max-age=1, private, must-revalidate" # END Caching RewriteEngine on #VideoHLS for DRM + RewriteRule ^playLink/?$ view/modePlayLink.php [QSA] RewriteRule ^videos/([^/]+)/(.*).key$ plugin/VideoHLS/downloadProtection.php?filename=$1&key=$2 [QSA] RewriteRule glyphicons-halflings-regular(.+)$ view/bootstrap/fonts/glyphicons-halflings-regular$1 [NC,L] RewriteRule ^meet/([0-9]+)/(.+)$ plugin/Meet/iframe.php?meet_schedule_id=$1&roomName=$2 [NC,L,QSA] RewriteRule ^meet/([0-9]+)$ plugin/Meet/iframe.php?meet_schedule_id=$1 [NC,L,QSA] RewriteRule ^live/([0-9]+)/(.+)$ plugin/Live/?live_servers_id=$1&c=$2 [NC,L,QSA] RewriteRule ^liveLink/([0-9]+).*$ plugin/LiveLinks/view/Live.php?link=$1 [NC,L,QSA] RewriteRule ^liveLinkEmbed/([0-9]+).*$ plugin/LiveLinks/view/Live.php?link=$1&embed=1 [NC,L,QSA] #main Files RewriteRule ^index.php$ view/index.php [NC,L] #RewriteRule ^index.php$ /view/index.php [NC,L] #RewriteRule ^$ view/ [NC,L] RewriteRule ^bootstrap/(.+)$ view/bootstrap/$1 [NC,L] RewriteRule bootstrap-select.js.map$ view/bootstrap/bootstrapSelectPicker/js/bootstrap-select.js.map$1 [NC,L] RewriteRule ^oembed/?(.+)$ view/oembed.php$1 [NC,L] RewriteRule ^js/(.+)$ view/js/$1 [NC,L] RewriteRule ^css/(.+)$ view/css/$1 [NC,L] RewriteRule ^img/(.+)$ view/img/$1 [NC,L] RewriteRule ^i/(.+)$ view/iframe.php?type=$1 [NC,L] RewriteRule ^videos/fonts/(.+)$ view/bootstrap/fonts/$1 [NC,L] RewriteRule ^page/([0-9]+)/?$ view/?page=$1 [QSA] RewriteRule ^videoOnly/?$ view/?type=video [NC,L] RewriteRule ^audioOnly/?$ view/?type=audio [NC,L] RewriteRule ^download$ view/downloadExternalVideo.php [NC,L] RewriteRule ^info$ view/info.php [NC,L] RewriteRule ^version$ view/info.php?version=1 [NC,L] RewriteRule ^downloadNow$ objects/downloadVideo.php [NC,L] RewriteRule ^getDownloadProgress$ objects/downloadVideoProgress.php [NC,L] RewriteRule ^status$ objects/status.json.php [NC,L] RewriteRule ^menu/([^!#$&'()*+,\/:;=?@[\]]+)/? plugin/TopMenu/seo.php?menuSeoUrlItem=$1 [QSA,L] RewriteRule ^admin/plugin/(.+)$ plugin/$1 [NC,L] RewriteRule ^trending/?$ view/trending.php [NC,L,QSA] RewriteRule ^about$ view/about.php [NC,L] RewriteRule ^contact$ view/contact.php [NC,L] RewriteRule ^sendEmail$ objects/sendEmail.json.php [NC,L] RewriteRule ^captcha$ objects/getCaptcha.php [NC,L] RewriteRule ^monitor/(.+)$ objects/ServerMonitor/$1 [NC,L] RewriteRule ^videosList$ view/videosList.php [NC,L] RewriteRule ^videosList/video/([^!#$&'()*,\/:;=?@[\]]+)/page/([0-9]+)/?$ view/videosList.php?videoName=$1&page=$2 [QSA] RewriteRule ^videosList/cat/([^!#$&'()*,\/:;=?@[\]]+)/video/([^!#$&'()*+,\/:;=?@[\]]+)/page/([0-9]+)/?$ view/videosList.php?catName=$1&videoName=$2&page=$3 [QSA] #for the category name RewriteRule ^cat/([^!#$&'()*+,\/:;=?@[\]]+)/?$ view/?catName=$1 [NC,L,QSA] RewriteRule ^cat/([^!#$&'()*+,\/:;=?@[\]]+)/page/([0-9]+)/?$ view/?catName=$1&page=$2 [NC,L,QSA] RewriteRule ^tag/([0-9-]+)(.*)?$ view/?tags_id=$1 [NC,L,QSA] #for the video name RewriteRule ^video/([^!#$&'()*,\/:;=?@[\]]+)/?$ view/?videoName=$1 [QSA] RewriteRule ^video/([^!#$&'()*,\/:;=?@[\]]+)/page/([0-9]+)/??$ view/?videoName=$1&page=$2 [QSA] RewriteRule ^v/([0-9]+)/?$ view/?v=$1 [QSA] RewriteRule ^v/([0-9]+)/page/([0-9]+)/??$ view/?v=$1&page=$2 [QSA] RewriteRule ^video/([0-9]+)/([^!#$&'()*,\/:;=?@[\]]+)/?$ view/?v=$1 [QSA] RewriteRule ^video/([0-9]+)/([^!#$&'()*,\/:;=?@[\]]+)/page/([0-9]+)/??$ view/?v=$1&page=$3 [QSA] RewriteRule ^evideo/([a-zA-z0-9=]+)/?$ view/?evideo=$1 [QSA] #for the video name RewriteRule ^cat/([^!#$&'()*,\/:;=?@[\]]+)/video/([^!#$&'()*+,\/:;=?@[\]]+)/?$ view/?catName=$1&videoName=$2 [QSA] RewriteRule ^cat/([^!#$&'()*,\/:;=?@[\]]+)/video/([^!#$&'()*+,\/:;=?@[\]]+)/page/([0-9]+)/?$ view/?catName=$1&videoName=$2&page=$3 [QSA] #for the embeded video name RewriteRule ^videoEmbeded/([0-9]+)/? view/videoEmbeded.php?v=$1 [QSA] RewriteRule ^videoEmbeded/([^!#$&'()*+,\/:;=?@[\]]+)/?$ view/videoEmbeded.php?videoName=$1 [QSA] RewriteRule ^cat/([^!#$&'()*,\/:;=?@[\]]+)/videoEmbeded/([^!#$&'()*+,\/:;=?@[\]]+)/?$ view/videoEmbeded.php?catName=$1&videoName=$2 [QSA] RewriteRule ^videoEmbed/([0-9]+)/? view/videoEmbeded.php?v=$1 [QSA] RewriteRule ^videoEmbed/([^!#$&'()*+,\/:;=?@[\]]+)/?$ view/videoEmbeded.php?videoName=$1 [QSA] RewriteRule ^vEmbed/([0-9]+)/?$ view/videoEmbeded.php?v=$1 [QSA] RewriteRule ^videoEmbed/([0-9]+)/([^!#$&'()*+,\/:;=?@[\]]+)/?$ view/videoEmbeded.php?v=$1 [QSA] RewriteRule ^evideoEmbed/([a-zA-z0-9=]+)/?$ view/videoEmbeded.php?evideo=$1 [QSA] RewriteRule ^plugin/([^!#$&'()*+,\/:;=?@[\]]+)/(.*)?$ plugin/$1/$2 [NC,L] RewriteRule ^upload$ view/mini-upload-form/ [NC,L] RewriteRule ^fileUpload$ view/mini-upload-form/upload.php [NC,L] RewriteRule ^uploadPoster/([0-9]+)/(jpg|gif)$ objects/uploadPoster.php?video_id=$1&type=$2 [NC,L] #for the Article name RewriteRule ^article/([^!#$&'()*,\/:;=?@[\]]+)/?$ view/?videoName=$1 [QSA] RewriteRule ^article/([^!#$&'()*,\/:;=?@[\]]+)/page/([0-9]+)/??$ view/?videoName=$1&page=$2 [QSA] RewriteRule ^article/([0-9]+)/([^!#$&'()*,\/:;=?@[\]]+)/?$ view/?v=$1 [QSA] RewriteRule ^article/([0-9]+)/([^!#$&'()*,\/:;=?@[\]]+)/page/([0-9]+)/??$ view/?v=$1&page=$3 [QSA] #for the embeded article name RewriteRule ^articleEmbed/([0-9]+)/? view/videoEmbeded.php?v=$1 [QSA] RewriteRule ^articleEmbed/([^!#$&'()*+,\/:;=?@[\]]+)/?$ view/videoEmbeded.php?videoName=$1 [QSA] RewriteRule ^cat/([^!#$&'()*,\/:;=?@[\]]+)/articleEmbed/([^!#$&'()*+,\/:;=?@[\]]+)/?$ view/videoEmbeded.php?catName=$1&videoName=$2 [QSA] RewriteRule ^articleEmbed/([0-9]+)/? view/videoEmbeded.php?v=$1 [QSA] RewriteRule ^articleEmbed/([^!#$&'()*+,\/:;=?@[\]]+)/?$ view/videoEmbeded.php?videoName=$1 [QSA] RewriteRule ^articleEmbed/([0-9]+)/([^!#$&'()*+,\/:;=?@[\]]+)/?$ view/videoEmbeded.php?v=$1 [QSA] #edit your own user RewriteRule ^user$ view/user.php [NC,L] RewriteRule ^user/([0-9]+)/foto.png$ view/userGetPhoto.php?users_id=$1 [QSA] #manager user RewriteRule ^users$ view/managerUsers.php [NC,L] RewriteRule ^users.json$ objects/users.json.php [NC,L] RewriteRule ^updateUser$ objects/userUpdate.json.php [NC,L] RewriteRule ^savePhoto$ objects/userSavePhoto.php [NC,L] RewriteRule ^saveBackground$ objects/userSaveBackground.php [NC,L] RewriteRule ^addNewUser$ objects/userAddNew.json.php [NC,L] RewriteRule ^deleteUser$ objects/userDelete.json.php [NC,L] RewriteRule ^recoverPass$ objects/userRecoverPass.php [NC,L] RewriteRule ^saveRecoverPassword$ objects/userRecoverPassSave.json.php [NC,L] RewriteRule ^signUp$ view/signUp.php [NC,L] RewriteRule ^createUser$ objects/userCreate.json.php [NC,L] RewriteRule ^usersGroups$ view/managerUsersGroups.php [NC,L] RewriteRule ^usersGroups.json$ objects/usersGroups.json.php [NC,L] RewriteRule ^addNewUserGroups$ objects/userGroupsAddNew.json.php [NC,L] RewriteRule ^deleteUserGroups$ objects/userGroupsDelete.json.php [NC,L] #manager category RewriteRule ^categories$ view/managerCategories.php [NC,L] RewriteRule ^categories.json$ objects/categories.json.php [NC,L] RewriteRule ^addNewCategory$ objects/categoryAddNew.json.php [NC,L] RewriteRule ^deleteCategory$ objects/categoryDelete.json.php [NC,L] + RewriteRule ^listCategories$ view/listCategories.php [NC,L] #manager plugin RewriteRule ^plugins$ view/managerPlugins.php [NC,L] RewriteRule ^plugins.json$ objects/plugins.json.php [NC,L] RewriteRule ^pluginsAvailable.json$ objects/pluginsAvailable.json.php [NC,L] RewriteRule ^pluginImport.json$ objects/pluginImport.json.php [NC,L] RewriteRule ^switchPlugin$ objects/pluginSwitch.json.php [NC,L] RewriteRule ^addDataObjectPlugin.json$ objects/pluginAddDataObject.json.php [NC,L] RewriteRule ^runDBScriptPlugin.json$ objects/pluginRunDatabaseScript.json.php [NC,L] #manager playList RewriteRule ^epg.xml$ plugin/PlayLists/epg.xml.php [NC,L,QSA] RewriteRule ^epg.json$ plugin/PlayLists/epg.json.php [NC,L,QSA] RewriteRule ^epg.html$ plugin/PlayLists/epg.html.php [NC,L,QSA] RewriteRule ^epg$ plugin/PlayLists/epg.php [NC,L,QSA] RewriteRule ^tv$ plugin/PlayLists/tv.php [NC,L,QSA] RewriteRule ^iptv$ plugin/PlayLists/iptv.php [NC,L,QSA] RewriteRule ^iptv/([^/]+)/?$ plugin/PlayLists/iptv.php?channelName=$1 [NC,L,QSA] RewriteRule ^playLists.json$ objects/playlists.json.php [NC,L] RewriteRule ^playListsVideos.json$ objects/playlistsVideos.json.php [NC,L] RewriteRule ^playListsFromUser.json/([0-9]+)/?$ objects/playlistsFromUser.json.php?users_id=$1 [NC,L] RewriteRule ^addNewPlayList$ objects/playlistAddNew.json.php [NC,L] RewriteRule ^playListAddVideo.json$ objects/playListAddVideo.json.php [NC,L] RewriteRule ^playlist/([0-9]+)/([0-9]+)/?$ view/?playlist_id=$1&playlist_index=$2 [NC,L] RewriteRule ^playlist/([0-9]+)/?$ view/?playlist_id=$1 [NC,L] RewriteRule ^removeVideoFromPlaylist/?$ objects/playlistRemoveVideo.php [NC,L] RewriteRule ^removePlaylist/?$ objects/playlistRemove.php [NC,L] RewriteRule ^renamePlaylist/?$ objects/playlistRename.php [NC,L] RewriteRule ^sortPlaylist/?$ objects/playlistSort.php [NC,L] RewriteRule ^mrss/?$ feed/index.php?mrss=1 [QSA] RewriteRule ^roku.json$ feed/index.php?roku=1 [QSA] RewriteRule ^channel/([^/]+)/roku.json$ feed/index.php?channelName=$1&roku=1 [QSA] RewriteRule ^channel/([^/]+)/feed/?$ feed/index.php?channelName=$1 [QSA] RewriteRule ^channel/([^/]+)/rss/?$ feed/index.php?channelName=$1 [QSA] RewriteRule ^channel/([^/]+)/mrss/?$ feed/index.php?channelName=$1&mrss=1 [QSA] RewriteRule ^channel/([^/]+) view/channel.php?channelName=$1 [QSA] RewriteRule ^channel/?$ view/channel.php [QSA] RewriteRule ^channels/?$ view/channels.php [NC,L] #playlist alias RewriteRule ^programs.json$ objects/playlists.json.php [QSA] RewriteRule ^program/([0-9]+)/([0-9]+)(/.*)?$ view/?playlist_id=$1&playlist_index=$2 [QSA] RewriteRule ^program/([0-9]+)(/.*)?$ view/?playlist_id=$1 [QSA] RewriteRule ^viewProgram/([0-9]+).*?$ view/channelProgram.php?program_id=$1 [QSA] RewriteRule ^favorite/?$ view/?playlist_id=favorite [QSA] RewriteRule ^watch-later/?$ view/?playlist_id=watch-later [QSA] #manager videos RewriteRule ^orphanFiles$ view/orphanFiles.php [NC,L] RewriteRule ^mvideos$ view/managerVideos.php [NC,L] RewriteRule ^videos.json$ objects/videos.json.php [NC,L] RewriteRule ^videosAndroid.json$ objects/videosAndroid.json.php [NC,L] RewriteRule ^videoAndroid.json$ objects/videoAndroid.json.php [NC,L] RewriteRule ^deleteVideo$ objects/videoDelete.json.php [NC,L] RewriteRule ^addNewVideo$ objects/videoAddNew.json.php [NC,L] RewriteRule ^refreshVideo$ objects/videoRefresh.json.php [NC,L] RewriteRule ^setStatusVideo$ objects/videoStatus.json.php [NC,L] RewriteRule ^setCategoryVideo$ objects/videoCategory.json.php [NC,L] RewriteRule ^rotateVideo$ objects/videoRotate.json.php [NC,L] # Subscribes RewriteRule ^subscribes$ view/managerSubscribes.php [NC,L] RewriteRule ^subscribes.json$ objects/subscribes.json.php [NC,L] RewriteRule ^subscribe.json$ objects/subscribe.json.php [NC,L] RewriteRule ^notifySubscribers.json$ objects/notifySubscribers.json.php [NC,L] RewriteRule ^aVideoQueueEncoder.json$ objects/aVideoQueueEncoder.json.php [NC,L] RewriteRule ^aVideoEncoder.json$ objects/aVideoEncoder.json.php [NC,L] RewriteRule ^aVideoEncoderChunk.json$ objects/aVideoEncoderChunk.json.php [NC,L] #comment RewriteRule ^comments$ view/managerComments.php [NC,L] RewriteRule ^saveComment$ objects/commentAddNew.json.php [NC,L] RewriteRule ^comments.json/([0-9]+)$ objects/comments.json.php?video_id=$1 [NC,L] RewriteRule ^login$ objects/login.json.php [NC,L] RewriteRule ^logoff$ objects/logoff.php [NC,L] RewriteRule ^like$ objects/like.json.php?like=1 [QSA] RewriteRule ^dislike$ objects/like.json.php?like=-1 [QSA] #manager configuration RewriteRule ^update/?$ view/update.php [NC,L] RewriteRule ^siteConfigurations$ view/configurations.php [NC,L] RewriteRule ^updateConfig$ objects/configurationUpdate.json.php [NC,L] RewriteRule ^charts$ view/charts.php [NC,L] RewriteRule ^help$ view/help.php [NC,L] # YouTube Sync RewriteRule ^youtubeUpload$ objects/youtubeUpload.json.php [NC,L] RewriteRule ^googleAdView$ view/googleAdView.php [NC,L] RewriteRule ^notifications.json$ objects/notifications.json.php [NC,L] RewriteRule ^sitemap.xml$ view/sitemap.xml.php [NC,L] RewriteRule ^robots.txt$ view/robots.txt.php [NC,L] RewriteRule ^videos/(.*)/index.m3u8$ view/hls.php?videoDirectory=$1 [NC,L,QSA] RewriteRule ^videos/(.*)/index.m3u8.mp4$ view/hls.php?playHLSasMP4=1&videoDirectory=$1 [NC,L,QSA] RewriteRule ^vast.xml/?([0-9]+)?$ plugin/AD_Server/VAST.php?campaign_has_videos_id=$1 [NC,L] RewriteRule ^videos/([^!#$&'()*+,\/:;=?@[\]]+(\.(mp4|webm|m3u8|mp3|ogg)))$ view/xsendfile.php?file=$1 [QSA] # if image do not exists RewriteCond %{REQUEST_URI} \.(jpg|jpeg|gif|png|ico)$ [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*)$ img/image404.php?image=$1 [NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule .*$ view/error.php [NC,L] # Compress HTML, CSS, JavaScript, Text, XML and fonts AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/vnd.ms-fontobject AddOutputFilterByType DEFLATE application/x-font AddOutputFilterByType DEFLATE application/x-font-opentype AddOutputFilterByType DEFLATE application/x-font-otf AddOutputFilterByType DEFLATE application/x-font-truetype AddOutputFilterByType DEFLATE application/x-font-ttf AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE font/opentype AddOutputFilterByType DEFLATE font/otf AddOutputFilterByType DEFLATE font/ttf AddOutputFilterByType DEFLATE image/svg+xml AddOutputFilterByType DEFLATE image/x-icon AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/javascript AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/xml AddType text/vtt .vtt #php_value post_max_size 4G #php_value upload_max_filesize 4G diff --git a/objects/category.php b/objects/category.php index 8f42af180..1396001f1 100644 --- a/objects/category.php +++ b/objects/category.php @@ -1,783 +1,856 @@ order); } function setOrder($order) { $this->order = intval($order); } function getUsers_id() { if (empty($this->users_id)) { $this->users_id = User::getId(); } return $this->users_id; } function getPrivate() { return $this->private; } function setUsers_id($users_id) { // only admin can change owner if (!empty($this->users_id) && !User::isAdmin()) { return false; } $this->users_id = intval($users_id); } function setPrivate($private) { $this->private = empty($private) ? 0 : 1; } function setName($name) { $this->name = xss_esc($name); } function setClean_name($clean_name) { $clean_name = preg_replace('/\W+/', '-', strtolower(cleanString($clean_name))); $this->clean_name = $clean_name; } function setNextVideoOrder($nextVideoOrder) { $this->nextVideoOrder = $nextVideoOrder; } function setParentId($parentId) { $this->parentId = $parentId; } /* function setType($type, $overwriteUserId = 0) { global $global; $internalId = $overwriteUserId; if (empty($internalId)) { $internalId = $this->id; } $exist = false; // require this cause of Video::autosetCategoryType - but should be moveable easy here.. require_once dirname(__FILE__) . '/../objects/video.php'; $sql = "SELECT * FROM `category_type_cache` WHERE categoryId = ?"; $res = sqlDAL::readSql($sql, "i", array($internalId)); $catTypeCache = sqlDAL::fetchAssoc($res); sqlDAL::close($res); if ($catTypeCache != false) { $exist = true; } if ($type == "3") { // auto-cat-type Video::autosetCategoryType($internalId); } else { if ($exist) { $sql = "UPDATE `category_type_cache` SET `type` = ?, `manualSet` = '1' WHERE `category_type_cache`.`categoryId` = ?;"; sqlDAL::writeSql($sql, "si", array($type, $internalId)); } else { $sql = "INSERT INTO `category_type_cache` (`categoryId`, `type`, `manualSet`) VALUES (?,?,'1')"; sqlDAL::writeSql($sql, "is", array($internalId, $type)); } } } * */ function setDescription($description) { $this->description = xss_esc($description); } function __construct($id, $name = '') { if (empty($id)) { // get the category data from category and pass $this->name = xss_esc($name); } else { $this->id = $id; // get data from id $this->load($id); } } private function load($id) { $row = self::getCategory($id); if (empty($row)) return false; foreach ($row as $key => $value) { $this->$key = $value; } return true; } function loadSelfCategory() { $this->load($this->getId()); } function save($allowOfflineUser = false) { global $global; if (!$allowOfflineUser && !self::canCreateCategory()) { return false; } if (!$allowOfflineUser && !empty($this->id) && !self::userCanEditCategory($this->id)) { return false; } if (empty($this->users_id)) { $this->users_id = User::getId(); } $this->clean_name = self::fixCleanTitle($this->clean_name, 1, $this->id); // check if clean name exists $exists = $this->getCategoryByName($this->clean_name); if (!empty($exists) && $exists['id'] != $this->id) { $this->clean_name .= uniqid(); } $this->nextVideoOrder = intval($this->nextVideoOrder); $this->parentId = intval($this->parentId); if (!empty($this->id)) { $sql = "UPDATE categories SET " . "name = ?," . "clean_name = ?," . "description = ?," . "nextVideoOrder = ?," . "parentId = ?," . "iconClass = ?," . "users_id = ?," . "`private` = ?, allow_download = ?, `order` = ?, modified = now() WHERE id = ?"; $format = "sssiisiiiii"; $values = array(xss_esc($this->name), xss_esc($this->clean_name), xss_esc($this->description), $this->nextVideoOrder, $this->parentId, $this->getIconClass(), $this->getUsers_id(), $this->getPrivate(), $this->getAllow_download(), $this->getOrder(), $this->id); } else { $sql = "INSERT INTO categories ( " . "name," . "clean_name," . "description," . "nextVideoOrder," . "parentId," . "iconClass, " . "users_id, " . "`private`, allow_download, `order`, created, modified) VALUES (?, ?,?,?,?,?,?,?,?,?,now(), now())"; $format = "sssiisiiii"; $values = array(xss_esc($this->name), xss_esc($this->clean_name), xss_esc($this->description), $this->nextVideoOrder, $this->parentId, $this->getIconClass(), $this->getUsers_id(), $this->getPrivate(), $this->getAllow_download(), $this->getOrder()); } $insert_row = sqlDAL::writeSql($sql, $format, $values); if ($insert_row) { $_SESSION['user']['sessionCache']['getAllCategoriesClearCache'] = 1; ObjectYPT::deleteALLCache(); if (empty($this->id)) { $id = $global['mysqli']->insert_id; } else { $id = $this->id; } return $id; } else { die($sql . ' Error : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error); } } static function fixCleanTitle($clean_title, $count, $id, $original_title = "") { global $global; if (empty($original_title)) { $original_title = $clean_title; } $sql = "SELECT * FROM categories WHERE clean_name = '{$clean_title}' "; if (!empty($id)) { $sql .= " AND id != {$id} "; } $sql .= " LIMIT 1"; $res = sqlDAL::readSql($sql, "", array(), true); $cleanTitleExists = sqlDAL::fetchAssoc($res); sqlDAL::close($res); if ($cleanTitleExists != false) { return self::fixCleanTitle($original_title . "-" . $count, $count + 1, $id, $original_title); } return $clean_title; } function delete() { if (!self::canCreateCategory()) { return false; } if (!self::userCanEditCategory($this->id)) { return false; } // cannot delete default category if ($this->id == 1) { return false; } global $global; if (!empty($this->id)) { $_SESSION['user']['sessionCache']['getAllCategoriesClearCache'] = 1; $categories_id = self::getSiteCategoryDefaultID(); if ($categories_id) { $sql = "UPDATE videos SET categories_id = ? WHERE categories_id = ?"; sqlDAL::writeSql($sql, "ii", array($categories_id, $this->id)); } $sql = "DELETE FROM categories WHERE id = ?"; } else { return false; } self::clearCacheCount(); self::deleteAssets($this->id); return sqlDAL::writeSql($sql, "i", array($this->id)); } static function deleteAssets($categories_id) { $dirPaths = self::getCategoryDirPath($categories_id); return rrmdir($dirPaths['path']); } /* static function getCategoryType($categoryId) { global $global; $sql = "SELECT * FROM `category_type_cache` WHERE categoryId = ?;"; $res = sqlDAL::readSql($sql, "i", array($categoryId)); $data = sqlDAL::fetchAssoc($res); sqlDAL::close($res); if ($res) { if (!empty($data)) { return $data; } else { return array("categoryId" => "-1", "type" => "0", "manualSet" => "0"); } } else { return array("categoryId" => "-1", "type" => "0", "manualSet" => "0"); } } * */ static function getCategory($id) { global $global; $id = intval($id); $sql = "SELECT * FROM categories WHERE id = ? LIMIT 1"; $res = sqlDAL::readSql($sql, "i", array($id)); $result = sqlDAL::fetchAssoc($res); sqlDAL::close($res); if ($result) { $result['name'] = xss_esc_back($result['name']); } return ($res) ? $result : false; } static function getCategoryByName($name) { global $global; $sql = "SELECT * FROM categories WHERE clean_name = ? LIMIT 1"; $res = sqlDAL::readSql($sql, "s", array($name)); $result = sqlDAL::fetchAssoc($res); sqlDAL::close($res); if ($result) { $result['name'] = xss_esc_back($result['name']); } return ($res) ? $result : false; } static function getOrCreateCategoryByName($name) { $cat = self::getCategoryByName($name); if (empty($cat)) { $obj = new Category(0); $obj->setName($name); $obj->setClean_name($name); $obj->setDescription(""); $obj->setIconClass(""); $obj->setNextVideoOrder(0); $obj->setParentId(0); $id = $obj->save(); return self::getCategoryByName($name); } return $cat; } static function getCategoryDefault() { global $global; $sql = "SELECT * FROM categories ORDER BY id ASC LIMIT 1"; $res = sqlDAL::readSql($sql); $result = sqlDAL::fetchAssoc($res); sqlDAL::close($res); if ($result) { $result['name'] = xss_esc_back($result['name']); } return ($res) ? $result : false; } static function getSiteCategoryDefaultID() { $obj = AVideoPlugin::getObjectDataIfEnabled("PredefinedCategory"); $id = false; if ($obj) { $id = $obj->defaultCategory; } else { $row = self::getCategoryDefault(); if ($row) { $id = $row['id']; } } return $id; } static function getAllCategories($filterCanAddVideoOnly = false, $onlyWithVideos = false) { global $global, $config; if ($config->currentVersionLowerThen('8.4')) { return false; } $sql = "SELECT * FROM categories c WHERE 1=1 "; if (!empty($_GET['parentsOnly'])) { $sql .= "AND parentId = 0 "; } if ($filterCanAddVideoOnly && !User::isAdmin()) { if (is_int($filterCanAddVideoOnly)) { $users_id = $filterCanAddVideoOnly; } else { $users_id = User::getId(); } if ($config->currentVersionGreaterThen('6.1')) { $sql .= " AND (private=0 OR users_id = '{$users_id}') "; } } if ($onlyWithVideos) { $sql .= " AND ((SELECT count(*) FROM videos v where v.categories_id = c.id OR categories_id IN (SELECT id from categories where parentId = c.id)) > 0 "; - if(AVideoPlugin::isEnabledByName("Live")){ + if (AVideoPlugin::isEnabledByName("Live")) { $sql .= " OR " . " (" . " SELECT count(*) FROM live_transmitions lt where " . " (lt.categories_id = c.id OR lt.categories_id IN (SELECT id from categories where parentId = c.id))" //. " AND lt.id = (select id FROM live_transmitions lt2 WHERE lt.users_id = lt2.users_id ORDER BY CREATED DESC LIMIT 1 )" . " ) > 0 "; } - if(AVideoPlugin::isEnabledByName("LiveLinks")){ + if (AVideoPlugin::isEnabledByName("LiveLinks")) { $sql .= " OR " . " (" . " SELECT count(*) FROM LiveLinks ll where " . " (ll.categories_id = c.id OR ll.categories_id IN (SELECT id from categories where parentId = c.id))" . " ) > 0 "; } $sql .= ")"; } if (isset($_POST['sort']['title'])) { unset($_POST['sort']['title']); } $sql .= BootGrid::getSqlFromPost(array('name'), "", " ORDER BY `order`, name ASC "); - + $cacheName = md5($sql); if (empty($_SESSION['user']['sessionCache']['getAllCategoriesClearCache'])) { $category = object_to_array(ObjectYPT::getCache($cacheName, 36000)); } else { _session_start(); unset($_SESSION['user']['sessionCache']['getAllCategoriesClearCache']); } if (empty($category)) { $res = sqlDAL::readSql($sql); $fullResult = sqlDAL::fetchAllAssoc($res); sqlDAL::close($res); $category = array(); if ($res) { foreach ($fullResult as $row) { - + $totals = self::getTotalFromCategory($row['id']); $fullTotals = self::getTotalFromCategory($row['id'], false, true, true); - + $row['name'] = xss_esc_back($row['name']); $row['total'] = $totals['total']; $row['fullTotal'] = $fullTotals['total']; $row['fullTotal_videos'] = $fullTotals['videos']; $row['fullTotal_lives'] = $fullTotals['lives']; $row['fullTotal_livelinks'] = $fullTotals['livelinks']; $row['owner'] = User::getNameIdentificationById(@$row['users_id']); $row['canEdit'] = self::userCanEditCategory($row['id']); $row['canAddVideo'] = self::userCanAddInCategory($row['id']); $row['hierarchy'] = self::getHierarchyString($row['parentId']); $row['hierarchyAndName'] = $row['hierarchy'] . $row['name']; $category[] = $row; } //$category = $res->fetch_all(MYSQLI_ASSOC); ObjectYPT::setCache($cacheName, $category); } else { $category = false; die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error); } } return $category; } static function getHierarchyArray($categories_id, $hierarchyArray = array()) { if (empty($categories_id)) { return $hierarchyArray; } $sql = "SELECT * FROM categories WHERE id=? "; $res = sqlDAL::readSql($sql, "i", array($categories_id)); $result = sqlDAL::fetchAssoc($res); sqlDAL::close($res); if ($result) { $hierarchyArray[] = $result; return self::getHierarchyArray($result['parentId'], $hierarchyArray); } return $hierarchyArray; } static function getHierarchyString($categories_id) { if (empty($categories_id)) { return "/"; } $array = array_reverse(self::getHierarchyArray($categories_id)); //$array = (self::getHierarchyArray($categories_id)); //var_dump($array);exit; if (empty($array)) { return "/"; } $str = "/"; foreach ($array as $value) { $str .= xss_esc_back($value['name']) . "/"; } return $str; } static function userCanAddInCategory($categories_id, $users_id = 0) { if (empty($categories_id)) { return false; } if (empty($users_id)) { $users_id = User::getId(); } if (empty($users_id)) { return false; } $cat = new Category($categories_id); if (empty($cat->getPrivate()) || $users_id == $cat->getUsers_id()) { return true; } return false; } static function userCanEditCategory($categories_id, $users_id = 0) { if (empty($categories_id)) { return false; } if (empty($users_id)) { $users_id = User::getId(); } if (empty($users_id)) { return false; } if (User::isAdmin()) { return true; } $cat = new Category($categories_id); if ($users_id == $cat->getUsers_id()) { return true; } return false; } static function canCreateCategory() { global $advancedCustomUser; if (User::isAdmin()) { return true; } if ($advancedCustomUser && $advancedCustomUser->usersCanCreateNewCategories && User::canUpload()) { return true; } return false; } static function getChildCategories($parentId, $filterCanAddVideoOnly = false) { global $global, $config; if ($config->currentVersionLowerThen('8.4')) { return false; } $sql = "SELECT * FROM categories WHERE parentId=? AND id!=? "; if ($filterCanAddVideoOnly && !User::isAdmin()) { if (is_int($filterCanAddVideoOnly)) { $users_id = $filterCanAddVideoOnly; } else { $users_id = User::getId(); } if ($config->currentVersionGreaterThen('6.1')) { $sql .= " AND (private=0 OR users_id = '{$users_id}') "; } } $sql .= BootGrid::getSqlFromPost(array('name'), "", " ORDER BY `order`, name ASC "); $res = sqlDAL::readSql($sql, "ii", array($parentId, $parentId)); $fullResult = sqlDAL::fetchAllAssoc($res); sqlDAL::close($res); $category = array(); if ($res) { foreach ($fullResult as $row) { $totals = self::getTotalFromCategory($row['id']); $row['name'] = xss_esc_back($row['name']); $row['total'] = $totals['total']; $row['total_array'] = $totals; $category[] = $row; } } else { $category = false; die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error); } return $category; } static function getChildCategoriesFromTitle($clean_title) { $row = self::getCategoryByName($clean_title); return self::getChildCategories($row['id']); } - static function getTotalFromCategory($categories_id, $showUnlisted = false, $getAllVideos = false, $renew = false) { $videos = self::getTotalVideosFromCategory($categories_id, $showUnlisted, $getAllVideos, $renew); $lives = self::getTotalLivesFromCategory($categories_id, $showUnlisted, $renew); $livelinkss = self::getTotalLiveLinksFromCategory($categories_id, $showUnlisted, $renew); - $total = $videos+$lives+$livelinkss; - return array('videos'=>$videos, 'lives'=>$lives, 'livelinks'=>$livelinkss, 'total'=>$total); + $total = $videos + $lives + $livelinkss; + return array('videos' => $videos, 'lives' => $lives, 'livelinks' => $livelinkss, 'total' => $total); } - + + static function getTotalFromChildCategory($categories_id, $showUnlisted = false, $getAllVideos = false, $renew = false) { + + $categories = self::getChildCategories($categories_id); + $array = array('videos' => 0, 'lives' => 0, 'livelinks' => 0, 'total' => 0); + foreach ($categories as $value) { + $totals = self::getTotalFromCategory($categories_id, $showUnlisted, $getAllVideos, $renew); + $array = array( + 'videos' => $array['videos'] + $totals['videos'], + 'lives' => $array['lives'] + $totals['lives'], + 'livelinks' => $array['livelinks'] + $totals['livelinks'], + 'total' => $array['total'] + $totals['total']); + $totals = self::getTotalFromChildCategory($value['id'], $showUnlisted, $getAllVideos, $renew); + $array = array( + 'videos' => $array['videos'] + $totals['videos'], + 'lives' => $array['lives'] + $totals['lives'], + 'livelinks' => $array['livelinks'] + $totals['livelinks'], + 'total' => $array['total'] + $totals['total']); + } + + return $array; + } + static function getTotalVideosFromCategory($categories_id, $showUnlisted = false, $getAllVideos = false, $renew = false) { global $global, $config; - if (true || $renew || empty($_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][intval($getAllVideos)]['videos'])) { + if ($renew || empty($_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][intval($getAllVideos)]['videos'])) { $sql = "SELECT count(id) as total FROM videos v WHERE 1=1 AND categories_id = ? "; if (User::isLogged()) { $sql .= " AND (v.status IN ('" . implode("','", Video::getViewableStatus($showUnlisted)) . "') OR (v.status='u' AND v.users_id ='" . User::getId() . "'))"; } else { $sql .= " AND v.status IN ('" . implode("','", Video::getViewableStatus($showUnlisted)) . "')"; } if (!$getAllVideos) { $sql .= Video::getUserGroupsCanSeeSQL(); } //echo $categories_id, $sql;exit; $res = sqlDAL::readSql($sql, "i", array($categories_id)); $fullResult = sqlDAL::fetchAllAssoc($res); sqlDAL::close($res); $total = empty($fullResult[0]['total']) ? 0 : intval($fullResult[0]['total']); $rows = self::getChildCategories($categories_id); foreach ($rows as $value) { $total += self::getTotalVideosFromCategory($value['id'], $showUnlisted, $getAllVideos, $renew); } _session_start(); $_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][intval($getAllVideos)]['videos'] = $total; } return $_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][intval($getAllVideos)]['videos']; } + + static function getLatestVideoFromCategory($categories_id, $showUnlisted = false, $getAllVideos = false) { + global $global, $config; + $sql = "SELECT * FROM videos v WHERE 1=1 AND (categories_id = ? OR categories_id IN (SELECT id from categories where parentId = ?))"; + + if (User::isLogged()) { + $sql .= " AND (v.status IN ('" . implode("','", Video::getViewableStatus($showUnlisted)) . "') OR (v.status='u' AND v.users_id ='" . User::getId() . "'))"; + } else { + $sql .= " AND v.status IN ('" . implode("','", Video::getViewableStatus($showUnlisted)) . "')"; + } + if (!$getAllVideos) { + $sql .= Video::getUserGroupsCanSeeSQL(); + } + $sql .= "ORDER BY created DESC LIMIT 1"; + //var_dump($sql, $categories_id); + $res = sqlDAL::readSql($sql, "ii", array($categories_id, $categories_id)); + $result = sqlDAL::fetchAssoc($res); + sqlDAL::close($res); + return $result; + } + + static function getLatestLiveFromCategory($categories_id) { + if (!AVideoPlugin::isEnabledByName("Live")) { + return array(); + } + global $global, $config; + $sql = "SELECT * FROM live_transmitions lt LEFT JOIN live_transmitions_history lth ON lt.users_id = lth.users_id " + . " WHERE 1=1 AND (categories_id = ? OR categories_id IN (SELECT id from categories where parentId = ?))"; + + $sql .= "ORDER BY lth.created DESC LIMIT 1"; + //var_dump($sql, $categories_id); + $res = sqlDAL::readSql($sql, "ii", array($categories_id, $categories_id)); + $result = sqlDAL::fetchAssoc($res); + sqlDAL::close($res); + return $result; + } + + static function getLatestLiveLinksFromCategory($categories_id) { + if (AVideoPlugin::isEnabledByName("LiveLinks")) { + return array(); + } + global $global, $config; + $sql = "SELECT * FROM livelinks WHERE 1=1 AND (categories_id = ? OR categories_id IN (SELECT id from categories where parentId = ?))"; + + $sql .= "ORDER BY created DESC LIMIT 1"; + //var_dump($sql, $categories_id); + $res = sqlDAL::readSql($sql, "ii", array($categories_id, $categories_id)); + $result = sqlDAL::fetchAssoc($res); + sqlDAL::close($res); + return $result; + } + static function getTotalLiveLinksFromCategory($categories_id, $showUnlisted = false, $renew = false) { global $global; - - if(!AVideoPlugin::isEnabledByName("LiveLinks")){ + + if (!AVideoPlugin::isEnabledByName("LiveLinks")) { return 0; } - + if ($renew || empty($_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][0]['livelinks'])) { $sql = "SELECT count(id) as total FROM LiveLinks v WHERE 1=1 AND categories_id = ? "; if (empty($showUnlisted)) { $sql .= " AND `type` = 'public' "; - } - + } + //echo $categories_id, $sql;exit; $res = sqlDAL::readSql($sql, "i", array($categories_id)); $fullResult = sqlDAL::fetchAllAssoc($res); sqlDAL::close($res); $total = empty($fullResult[0]['total']) ? 0 : intval($fullResult[0]['total']); $rows = self::getChildCategories($categories_id); foreach ($rows as $value) { $total += self::getTotalLivesFromCategory($value['id'], $showUnlisted, $renew); } _session_start(); $_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][0]['livelinks'] = $total; } return $_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][0]['livelinks']; } - + static function getTotalLivesFromCategory($categories_id, $showUnlisted = false, $renew = false) { - - - if(!AVideoPlugin::isEnabledByName("Live")){ + + + if (!AVideoPlugin::isEnabledByName("Live")) { return 0; } - + global $global; if ($renew || empty($_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][0]['live'])) { $sql = "SELECT count(id) as total FROM live_transmitions v WHERE 1=1 AND categories_id = ? "; if (empty($showUnlisted)) { $sql .= " AND public = 1 "; - } - + } + //echo $categories_id, $sql;exit; $res = sqlDAL::readSql($sql, "i", array($categories_id)); $fullResult = sqlDAL::fetchAllAssoc($res); sqlDAL::close($res); $total = empty($fullResult[0]['total']) ? 0 : intval($fullResult[0]['total']); $rows = self::getChildCategories($categories_id); foreach ($rows as $value) { $total += self::getTotalLivesFromCategory($value['id'], $showUnlisted, $renew); } _session_start(); $_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][0]['live'] = $total; } return $_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][0]['live']; } - static function clearCacheCount($categories_id=0) { + static function clearCacheCount($categories_id = 0) { // clear category count cache _session_start(); - if(empty($categories_id)){ + if (empty($categories_id)) { unset($_SESSION['user']['sessionCache']['categoryTotal']); $_SESSION['user']['sessionCache']['getAllCategoriesClearCache'] = 1; - }else{ + } else { unset($_SESSION['user']['sessionCache']['categoryTotal'][$categories_id]); } //session_write_close(); } static function getTotalCategories($filterCanAddVideoOnly = false) { global $global, $config; if ($config->currentVersionLowerThen('5.01')) { return false; } $sql = "SELECT id, parentId FROM categories WHERE 1=1 "; if ($filterCanAddVideoOnly && !User::isAdmin()) { if (is_int($filterCanAddVideoOnly)) { $users_id = $filterCanAddVideoOnly; } else { $users_id = User::getId(); } if ($config->currentVersionGreaterThen('6.1')) { $sql .= " AND (private=0 OR users_id = '{$users_id}') "; } } if (!empty($_GET['parentsOnly'])) { $sql .= "AND parentId = 0 OR parentId = -1 "; } $sql .= BootGrid::getSqlSearchFromPost(array('name')); $res = sqlDAL::readSql($sql); $numRows = sqlDal::num_rows($res); sqlDAL::close($res); return $numRows; } function getIconClass() { if (empty($this->iconClass)) { return "fa fa-folder"; } return $this->iconClass; } function setIconClass($iconClass) { $this->iconClass = $iconClass; } function getName() { return $this->name; } function getClean_name() { return $this->clean_name; } function getDescription() { return $this->description; } function getAllow_download() { return $this->allow_download; } function setAllow_download($allow_download) { $this->allow_download = intval($allow_download); } static function getCategoryDirPath($categories_id = "") { global $global; $dir = "videos/categories/assets/"; if (!empty($categories_id)) { $dir .= $categories_id . "/"; } $path = array(); $path['dir'] = "{$global['systemRootPath']}{$dir}"; make_path($path['dir']); $path['path'] = "{$global['systemRootPath']}{$dir}"; $path['url'] = "{$global['webSiteRootURL']}{$dir}"; return $path; } static function isAssetsValids($categories_id) { $photo = Category::getCategoryPhotoPath($categories_id); $background = Category::getCategoryBackgroundPath($categories_id); - if(!file_exists($photo['path']) || !file_exists($background['path'])){ + if (!file_exists($photo['path']) || !file_exists($background['path'])) { return false; } return true; } static function getCategoryPhotoPath($categories_id) { return self::getCategoryAssetPath("photo.png", $categories_id); } static function getCategoryBackgroundPath($categories_id) { return self::getCategoryAssetPath("background.png", $categories_id); } private static function getCategoryAssetPath($name, $categories_id) { if (empty($categories_id)) { return false; } if (empty($name)) { return false; } $dirPaths = self::getCategoryDirPath($categories_id); global $global; $path = array(); $path['dir'] = $dirPaths['url']; $path['path'] = "{$dirPaths['path']}{$name}"; $path['url'] = "{$dirPaths['url']}{$name}"; if (file_exists($path['path'])) { $path['url+timestamp'] = "{$path['url']}?" . filectime($path['path']); } else { $path['url+timestamp'] = $path['url']; } return $path; } } diff --git a/objects/status.json.php b/objects/status.json.php index 2834fd7cf..a79c0b984 100644 --- a/objects/status.json.php +++ b/objects/status.json.php @@ -1,39 +1,39 @@ max_file_size = get_max_file_size(); $obj->file_upload_max_size = file_upload_max_size(); $obj->videoStorageLimitMinutes = $global['videoStorageLimitMinutes']; $obj->currentStorageUsage = getSecondsTotalVideosLength(); $obj->webSiteLogo = $config->getLogo(true); $obj->webSiteTitle = $config->getWebSiteTitle(); $obj->PHPSESSID = session_id(); $obj->version = $config->getVersion(); $obj->mobileSreamerVersion = MobileManager::getVersion(); $obj->reportVideoPluginEnabled = AVideoPlugin::isEnabledByName("ReportVideo"); $obj->oauthLogin = array(); $obj->oauthLogin[] = array('type'=>'Facebook', 'status'=> !empty(AVideoPlugin::loadPluginIfEnabled('LoginFacebook'))); $obj->oauthLogin[] = array('type'=>'Google', 'status'=> !empty(AVideoPlugin::loadPluginIfEnabled('LoginGoogle'))); $obj->oauthLogin[] = array('type'=>'Twitter', 'status'=> !empty(AVideoPlugin::loadPluginIfEnabled('LoginTwitter'))); $obj->oauthLogin[] = array('type'=>'LinkedIn', 'status'=> !empty(AVideoPlugin::loadPluginIfEnabled('LoginLinkedin'))); $obj->plugins = array(); $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { $p = AVideoPlugin::loadPlugin($value['dirName']); if (is_object($p)) { $info = $p->getMobileInfo(); if(!empty($info)){ $obj->plugins[$value['dirName']] = $info; } } } echo json_encode($obj); diff --git a/plugin/CustomizeAdvanced/CustomizeAdvanced.php b/plugin/CustomizeAdvanced/CustomizeAdvanced.php index 86324e82e..4359c7a11 100644 --- a/plugin/CustomizeAdvanced/CustomizeAdvanced.php +++ b/plugin/CustomizeAdvanced/CustomizeAdvanced.php @@ -1,347 +1,348 @@ Help"; return $txt . $help; } public function getName() { return "CustomizeAdvanced"; } public function getUUID() { return "55a4fa56-8a30-48d4-a0fb-8aa6b3f69033"; } public function getPluginVersion() { return "1.0"; } public function getEmptyDataObject() { global $global; $obj = new stdClass(); $obj->logoMenuBarURL = ""; $obj->encoderNetwork = "https://network.avideo.com/"; $obj->useEncoderNetworkRecomendation = false; $obj->doNotShowEncoderNetwork = true; $obj->doNotShowUploadButton = false; $obj->uploadButtonDropdownIcon = "fas fa-video"; $obj->uploadButtonDropdownText = ""; $obj->encoderNetworkLabel = ""; $obj->doNotShowUploadMP4Button = true; $obj->disablePDFUpload = false; $obj->disableImageUpload = false; $obj->disableZipUpload = true; $obj->disableMP4Upload = false; $obj->disableMP3Upload = false; $obj->uploadMP4ButtonLabel = ""; $obj->doNotShowImportMP4Button = true; $obj->importMP4ButtonLabel = ""; $obj->doNotShowEncoderButton = false; $obj->encoderButtonLabel = ""; $obj->doNotShowEmbedButton = false; $obj->embedBackgroundColor = "white"; $obj->embedButtonLabel = ""; $obj->embedCodeTemplate = '
'; $obj->embedCodeTemplateObject = '
'; $obj->htmlCodeTemplate = '{title}'; $obj->BBCodeTemplate = '[url={permaLink}][img]{imgSRC}[/img]{title}[/url]'; $obj->doNotShowEncoderHLS = false; $obj->doNotShowEncoderResolutionLow = false; $obj->doNotShowEncoderResolutionSD = false; $obj->doNotShowEncoderResolutionHD = false; $obj->openEncoderInIFrame = false; $obj->showOnlyEncoderAutomaticResolutions = true; $obj->doNotShowEncoderAutomaticHLS = false; $obj->doNotShowEncoderAutomaticMP4 = false; $obj->doNotShowEncoderAutomaticWebm = false; $obj->doNotShowEncoderAutomaticAudio = false; $obj->doNotShowExtractAudio = false; $obj->doNotShowCreateVideoSpectrum = false; $obj->doNotShowLeftMenuAudioAndVideoButtons = false; $obj->doNotShowWebsiteOnContactForm = false; $obj->doNotUseXsendFile = false; $obj->makeVideosInactiveAfterEncode = false; $obj->makeVideosUnlistedAfterEncode = false; $obj->usePermalinks = false; $obj->useVideoIDOnSEOLinks = true; $obj->disableAnimatedGif = false; $obj->removeBrowserChannelLinkFromMenu = false; $obj->EnableWavesurfer = false; $obj->EnableMinifyJS = false; $obj->disableShareAndPlaylist = false; $obj->disableShareOnly = false; $obj->disableEmailSharing = false; $obj->splitBulkEmailSend = 50; $obj->disableComments = false; $obj->commentsMaxLength = 200; $obj->commentsNoIndex = false; $obj->disableYoutubePlayerIntegration = false; $obj->utf8Encode = false; $obj->utf8Decode = false; $o = new stdClass(); $o->type = "textarea"; $o->value = ""; $obj->menuBarHTMLCode = $o; $o->type = "textarea"; $o->value = ""; $obj->underMenuBarHTMLCode = $o; $o->type = "textarea"; $o->value = ""; $obj->footerHTMLCode = $o; $obj->signInOnRight = true; $obj->signInOnLeft = true; $obj->forceCategory = false; $obj->showCategoryTopImages = true; $obj->autoPlayAjax = false; $plugins = Plugin::getAllEnabled(); //import external plugins configuration options foreach ($plugins as $value) { $p = AVideoPlugin::loadPlugin($value['dirName']); if (is_object($p)) { $foreginObjects = $p->getCustomizeAdvancedOptions(); if ($foreginObjects) { foreach ($foreginObjects as $optionName => $defaultValue) $obj->{$optionName} = $defaultValue; } } } + $obj->disablePlayLink = false; $obj->disableHelpLeftMenu = false; $obj->disableAboutLeftMenu = false; $obj->disableContactLeftMenu = false; $obj->disableNavbar = false; $obj->disableNavBarInsideIframe = true; $obj->autoHideNavbar = true; $obj->autoHideNavbarInSeconds = 0; $obj->videosCDN = ""; $obj->useFFMPEGToGenerateThumbs = false; $obj->thumbsWidthPortrait = 170; $obj->thumbsHeightPortrait = 250; $obj->thumbsWidthLandscape = 640; $obj->thumbsHeightLandscape = 360; $obj->showImageDownloadOption = false; $obj->doNotDisplayViews = false; $obj->doNotDisplayLikes = false; $obj->doNotDisplayCategoryLeftMenu = false; $obj->doNotDisplayCategory = false; $obj->doNotDisplayGroupsTags = false; $obj->doNotDisplayPluginsTags = false; $obj->showNotRatedLabel = false; $obj->showShareMenuOpenByDefault = false; $obj->askRRatingConfirmationBeforePlay_G = false; $obj->askRRatingConfirmationBeforePlay_PG = false; $obj->askRRatingConfirmationBeforePlay_PG13 = false; $obj->askRRatingConfirmationBeforePlay_R = false; $obj->askRRatingConfirmationBeforePlay_NC17 = true; $obj->askRRatingConfirmationBeforePlay_MA = true; $obj->filterRRating = false; $obj->AsyncJobs = false; $obj->doNotShowLeftHomeButton = false; $obj->doNotShowLeftTrendingButton = false; $obj->CategoryLabel = "Categories"; $obj->ShowAllVideosOnCategory = false; $obj->hideCategoryVideosCount = false; //ver 7.1 $obj->paidOnlyUsersTellWhatVideoIs = false; $obj->paidOnlyShowLabels = false; $obj->paidOnlyLabel = "Premium"; $obj->paidOnlyFreeLabel = "Free"; $obj->removeSubscribeButton = false; $obj->removeThumbsUpAndDown = false; $o = new stdClass(); $o->type = "textarea"; $o->value = ""; $obj->videoNotFoundText = $o; $obj->siteMapRowsLimit = 100; $obj->siteMapUTF8Fix = false; $obj->showPrivateVideosOnSitemap = false; $obj->enableOldPassHashCheck = true; $obj->disableHTMLDescription = false; $obj->disableVideoSwap = false; $obj->makeSwapVideosOnlyForAdmin = false; $obj->disableCopyEmbed = false; $obj->disableDownloadVideosList = false; $obj->videosManegerRowCount = "[10, 25, 50, -1]"; //An Array of Integer which will be shown in the dropdown box to choose the row count. Default value is [10, 25, 50, -1]. -1 means all. When passing an Integer value the dropdown box will disapear. $obj->videosListRowCount = "[10, 20, 30, 40, 50]"; //An Array of Integer which will be shown in the dropdown box to choose the row count. Default value is [10, 25, 50, -1]. -1 means all. When passing an Integer value the dropdown box will disapear. $parse = parse_url($global['webSiteRootURL']); $domain = str_replace(".", "", $parse['host']); $obj->twitter_site = "@{$domain}"; $obj->twitter_player = true; $obj->twitter_summary_large_image = false; $obj->footerStyle = "position: fixed;bottom: 0;width: 100%;"; $obj->disableVideoTags = false; $o = new stdClass(); $o->type = DateTimeZone::listIdentifiers(DateTimeZone::ALL); $o->value = 0; $obj->timeZone = $o; $obj->keywords = "AVideo, videos, live, movies"; return $obj; } public function getHelp() { if (User::isAdmin()) { return "

CustomizeAdvanced (admin)

" . $this->getDescription() . "

EnableWavesurferEnables the visualisation for audio. This will always download full audio first, so with big audio-files, you might better disable it.
commentsMaxLengthMaximum lenght for comments in videos
disableYoutubePlayerIntegration Disables the integrating of youtube-videos and just embed them.
EnableMinifyJSMinify your JS. Clear videos/cache after changing this option.
"; } return ""; } public function getModeYouTube($videos_id) { global $global, $config; $obj = $this->getDataObject(); $video = Video::getVideo($videos_id, "viewable", true); if (!empty($video['rrating']) && empty($_GET['rrating'])) { $suffix = strtoupper(str_replace("-", "", $video['rrating'])); eval("\$show = \$obj->askRRatingConfirmationBeforePlay_$suffix;"); if (!empty($show)) { include "{$global['systemRootPath']}plugin/CustomizeAdvanced/confirmRating.php"; exit; } } } public function getFooterCode() { global $global; $obj = $this->getDataObject(); $content = ''; if ($obj->disableNavBarInsideIframe) { $content .= ''; } if ($obj->autoHideNavbar && !isEmbed()) { $content .= ''; $content .= ''; } if ($obj->autoHideNavbarInSeconds && !isEmbed()) { $content .= ''; } return $content; } public function getHTMLMenuRight() { global $global; $obj = $this->getDataObject(); if ($obj->filterRRating) { include $global['systemRootPath'] . 'plugin/CustomizeAdvanced/menuRight.php'; } } public function getHTMLMenuLeft() { global $global; $obj = $this->getDataObject(); if ($obj->filterRRating) { include $global['systemRootPath'] . 'plugin/CustomizeAdvanced/menuLeft.php'; } } public static function getVideoWhereClause() { $sql = ""; $obj = AVideoPlugin::getObjectData("CustomizeAdvanced"); if ($obj->filterRRating && isset($_GET['rrating'])) { if ($_GET['rrating'] === "0") { $sql .= " AND v.rrating = ''"; } else if (in_array($_GET['rrating'], Video::$rratingOptions)) { $sql .= " AND v.rrating = '{$_GET['rrating']}'"; } } return $sql; } public function getVideosManagerListButton() { $btn = ""; if (User::isAdmin()) { $btn = ''; $btn .= ''; } return $btn; } public function getHeadCode() { global $global; $obj = $this->getDataObject(); $baseName = basename($_SERVER['REQUEST_URI']); $js = ""; if(empty($obj->autoPlayAjax)){ $js .= ""; }else{ $js .= ""; } if ($baseName === 'mvideos') { $js .= ""; $js .= ""; } return $js; } } diff --git a/plugin/Live/Live.php b/plugin/Live/Live.php index 493de3877..a2c400e2c 100644 --- a/plugin/Live/Live.php +++ b/plugin/Live/Live.php @@ -1,1514 +1,1514 @@ and receive HLS streaming from servers"; $lu = AVideoPlugin::loadPlugin("LiveUsers"); if (!empty($lu)) { if (version_compare($lu->getPluginVersion(), "2.0") < 0) { $desc .= "
You MUST update your LiveUsers plugin to version 2.0 or greater
"; } } return $desc; } public function getName() { return "Live"; } public function getHTMLMenuRight() { global $global; $buttonTitle = $this->getButtonTitle(); $obj = $this->getDataObject(); if (!empty($obj->hideTopButton)) { return ''; } include $global['systemRootPath'] . 'plugin/Live/view/menuRight.php'; } public function getUUID() { return "e06b161c-cbd0-4c1d-a484-71018efa2f35"; } public function getPluginVersion() { return "5.3"; } public function updateScript() { global $global; //update version 2.0 $sql = "SELECT 1 FROM live_transmitions_history LIMIT 1"; $res = sqlDAL::readSql($sql); $fetch = sqlDAL::fetchAssoc($res); if (!$fetch) { sqlDal::writeSql(file_get_contents($global['systemRootPath'] . 'plugin/Live/install/updateV2.0.sql')); } //update version 3.0 $sql = "SELECT 1 FROM live_transmition_history_log LIMIT 1"; $res = sqlDAL::readSql($sql); $fetch = sqlDAL::fetchAssoc($res); if (!$fetch) { sqlDal::writeSql(file_get_contents($global['systemRootPath'] . 'plugin/Live/install/updateV3.0.sql')); } //update version 4.0 $sql = "SELECT 1 FROM live_servers LIMIT 1"; $res = sqlDAL::readSql($sql); $fetch = sqlDAL::fetchAssoc($res); if (!$fetch) { $sqls = file_get_contents($global['systemRootPath'] . 'plugin/Live/install/updateV4.0.sql'); $sqlParts = explode(";", $sqls); foreach ($sqlParts as $value) { sqlDal::writeSql(trim($value)); } } //update version 5.0 $sql = "SELECT 1 FROM live_restreams LIMIT 1"; $res = sqlDAL::readSql($sql); $fetch = sqlDAL::fetchAssoc($res); if (!$fetch) { $sqls = file_get_contents($global['systemRootPath'] . 'plugin/Live/install/updateV5.0.sql'); $sqlParts = explode(";", $sqls); foreach ($sqlParts as $value) { sqlDal::writeSql(trim($value)); } } //update version 5.1 if (AVideoPlugin::compareVersion($this->getName(), "5.1") < 0) { $sqls = file_get_contents($global['systemRootPath'] . 'plugin/Live/install/updateV5.1.sql'); $sqlParts = explode(";", $sqls); foreach ($sqlParts as $value) { sqlDal::writeSql(trim($value)); } } //update version 5.2 if (AVideoPlugin::compareVersion($this->getName(), "5.2") < 0) { $sqls = file_get_contents($global['systemRootPath'] . 'plugin/Live/install/updateV5.2.sql'); $sqlParts = explode(";", $sqls); foreach ($sqlParts as $value) { sqlDal::writeSql(trim($value)); } } //update version 5.2 if (AVideoPlugin::compareVersion($this->getName(), "6.0") < 0) { $sqls = file_get_contents($global['systemRootPath'] . 'plugin/Live/install/updateV6.0.sql'); $sqlParts = explode(";", $sqls); foreach ($sqlParts as $value) { sqlDal::writeSql(trim($value)); } } return true; } public function getEmptyDataObject() { global $global; $server = parse_url($global['webSiteRootURL']); $scheme = "http"; $port = "8080"; if (strtolower($server["scheme"]) == "https") { $scheme = "https"; $port = "8443"; } $obj = new stdClass(); $obj->button_title = "LIVE"; self::addDataObjectHelper('button_title', 'Button Title', 'This is the title that will appear in your button to enter in the Live panel'); $obj->server = "rtmp://{$server['host']}/live"; self::addDataObjectHelper('server', 'RTMP Server URL', 'Usually it is ' . "rtmp://{$server['host']}/live"); $obj->playerServer = "{$scheme}://{$server['host']}:{$port}/live"; self::addDataObjectHelper('playerServer', 'Player URL', 'This is a URL to your NGINX server, this URL will be used by the HTML5 player, If your site is HTTPS your player URL MUST be HTTPS as well, usually it is ' . "{$scheme}://{$server['host']}:{$port}/live"); $obj->stats = "{$scheme}://{$server['host']}:{$port}/stat"; self::addDataObjectHelper('stats', 'Stats Page URL', 'When you installed the NGINX you also install the stat.xsl, we will use it to grab the information when you have livestreams running, usually it is ' . "{$scheme}://{$server['host']}:{$port}/stat"); $obj->restreamerURL = "{$global['webSiteRootURL']}plugin/Live/standAloneFiles/restreamer.json.php"; self::addDataObjectHelper('restreamerURL', 'Restreamer URL', 'https://github.com/WWBN/AVideo/wiki/Restream'); $obj->controlURL = "{$global['webSiteRootURL']}plugin/Live/standAloneFiles/control.json.php"; self::addDataObjectHelper('controlURL', 'Control URL', 'Still under development'); $obj->disableRestream = false; self::addDataObjectHelper('disableRestream', 'Disable Restream', 'If you check this, we will not send requests to your Restreamer URL'); $obj->disableDVR = false; self::addDataObjectHelper('disableDVR', 'Disable DVR', 'Enable or disable the DVR Feature, you can control the DVR length in your nginx.conf on the parameter hls_playlist_length'); $obj->disableGifThumbs = false; self::addDataObjectHelper('disableGifThumbs', 'Disable Gif Thumbs', 'This option will disable the Animated Gif render, it will save some hardware capacity from your encoder and may speedup your page'); $obj->disableLiveThumbs = false; self::addDataObjectHelper('disableLiveThumbs', 'Disable Live thumbnails', 'This option will disable the çive image extraction and will use the user static image, it will save some hardware capacity from your encoder and may speedup your page'); $obj->hideTopButton = false; self::addDataObjectHelper('hideTopButton', 'Hide Top Button', 'This will hide the "Go Live" button on the top menu bar'); $obj->useAadaptiveMode = false; self::addDataObjectHelper('useAadaptiveMode', 'Adaptive mode', 'https://github.com/WWBN/AVideo/wiki/Adaptive-Bitrates-on-Livestream'); $obj->protectLive = false; self::addDataObjectHelper('protectLive', 'Live Protection', 'With this your encryption key will be protected, and only your site player will be able to play your videos, download tools will not be able to download your video. if you want to share your live externally you can use the embed and you will still be protected. but if you want to use the m3u8 file you must disable this'); $obj->experimentalWebcam = false; self::addDataObjectHelper('experimentalWebcam', 'Experimental Webcam', 'Requires flash and it is deprecated, will be removed. not recommend to enable it.'); $obj->doNotShowLiveOnVideosList = false; self::addDataObjectHelper('doNotShowLiveOnVideosList', 'Do not show live on videos list', 'We will not show the live thumbs on the main Gallery page'); $obj->doNotShowLiveOnCategoryList = false; self::addDataObjectHelper('doNotShowLiveOnCategoryList', 'Do not show live on site category list', 'We will not show the live thumbs on the main Gallery page'); $obj->doNotShowOfflineLiveOnCategoryList = false; self::addDataObjectHelper('doNotShowOfflineLiveOnCategoryList', 'Do not show offline lives on site category list', 'We will not show the live thumbs on the main Gallery page if it is offline'); $obj->limitLiveOnVideosList = 12; self::addDataObjectHelper('limitLiveOnVideosList', 'Videos List Limit', 'This will limit the maximum of videos that you will see in the Videos page'); //$obj->doNotShowGoLiveButton = false; //self::addDataObjectHelper('doNotShowGoLiveButton', 'Hide Top Button', 'This will hide the "Go Live" button on the top menu bar'); $obj->doNotProcessNotifications = false; self::addDataObjectHelper('doNotProcessNotifications', 'Do not show notifications', 'Do not show the notification on the top bar'); $obj->useLiveServers = false; self::addDataObjectHelper('useLiveServers', 'Use Live Servers', 'Check this if you will use External Live Servers https://github.com/WWBN/AVideo/wiki/Live-Plugin#livestream-server-balance '); $obj->disableMeetCamera = false; self::addDataObjectHelper('disableMeetCamera', 'Disable Meet camera', 'This requires out Meet Server, with the Meet camera you can use your PC webcam directly in the webpage or mobile to make livestreams'); $obj->playLiveInFullScreen = false; self::addDataObjectHelper('playLiveInFullScreen', 'Play Livestream in Full Screen'); $obj->playLiveInFullScreenOnIframe = false; self::addDataObjectHelper('playLiveInFullScreenOnIframe', 'Play Livestream in Full Screen on IFrame'); $obj->hls_path = "/HLS/live"; self::addDataObjectHelper('hls_path', 'HLS Path URL', 'Used only when we stop a Live, we use this path to delete the files'); $obj->requestStatsTimout = 4; // if the server does not respond we stop wait self::addDataObjectHelper('requestStatsTimout', 'Stats Timout', 'If a remote server (stats page) does not respond we stop waiting after this timeout'); $obj->cacheStatsTimout = 15; // we will cache the result self::addDataObjectHelper('cacheStatsTimout', 'Stats Cache Timeout', 'we will cache the result, this will save some resources'); $obj->requestStatsInterval = 15; // how many seconds untill request the stats again self::addDataObjectHelper('requestStatsInterval', 'Stats Request Interval', 'how many seconds until request the stats again'); $obj->streamDeniedMsg = "You can not stream live videos"; self::addDataObjectHelper('streamDeniedMsg', 'Denied Message', 'We will show this message when a user is not allowed so watch a livestream'); return $obj; } public function getHeadCode() { global $global; $obj = $this->getDataObject(); // preload image $js = ""; $css = ''; if (!empty($obj->playLiveInFullScreen)) { if ((isLive() || isEmbed()) && canFullScreen()) { $css .= ''; $css .= ''; } $js .= ''; $css .= ''; } return $js . $css; } public function getFooterCode() { $obj = $this->getDataObject(); global $global; $js = ''; if (!empty($obj->playLiveInFullScreen)) { $js = ''; $js .= ''; }else if (!empty($obj->playLiveInFullScreenOnIframe)) { $js = ''; $js .= ''; } include $global['systemRootPath'].'plugin/Live/view/footer.php'; return $js; } public function getButtonTitle() { $o = $this->getDataObject(); return $o->button_title; } public function getKey() { $o = $this->getDataObject(); return $o->key; } static function getDestinationApplicationName() { $server = self::getPlayerServer(); $server = rtrim($server, "/"); $parts = explode("/", $server); $app = array_pop($parts); $domain = self::getControl(); //return "{$domain}/control/drop/publisher?app={$app}&name={$key}"; return "{$app}?p=" . User::getUserPass(); } static function getDestinationHost() { $server = self::getServer(); $host = parse_url($server, PHP_URL_HOST); return $host; } static function getDestinationPort() { $server = self::getServer(); $port = parse_url($server, PHP_URL_PORT); if (empty($port)) { $port = 1935; } return $port; } static function getServer($live_servers_id = -1) { $obj = AVideoPlugin::getObjectData("Live"); if (!empty($obj->useLiveServers)) { if ($live_servers_id < 0) { $live_servers_id = self::getCurrentLiveServersId(); } $ls = new Live_servers($live_servers_id); if (!empty($ls->getRtmp_server())) { return $ls->getRtmp_server(); } } return $obj->server; } static function getDropURL($key) { $server = self::getPlayerServer(); $server = rtrim($server, "/"); $parts = explode("/", $server); $app = array_pop($parts); $domain = self::getControl(); //return "{$domain}/control/drop/publisher?app={$app}&name={$key}"; return "{$domain}?command=drop_publisher&app={$app}&name={$key}&token=" . getToken(60); } static function getIsRecording($key) { $server = self::getPlayerServer(); $server = rtrim($server, "/"); $parts = explode("/", $server); $app = array_pop($parts); $domain = self::getControl(); //return "{$domain}/control/drop/publisher?app={$app}&name={$key}"; return "{$domain}?command=is_recording&app={$app}&name={$key}&token=" . getToken(60); } static function getStartRecordURL($key) { $server = self::getPlayerServer(); $server = rtrim($server, "/"); $parts = explode("/", $server); $app = array_pop($parts); $domain = self::getControl(); //return "{$domain}/control/drop/publisher?app={$app}&name={$key}"; return "{$domain}?command=record_start&app={$app}&name={$key}&token=" . getToken(60); } static function getStopRecordURL($key) { $server = self::getPlayerServer(); $server = rtrim($server, "/"); $parts = explode("/", $server); $app = array_pop($parts); $domain = self::getControl(); return "{$domain}?command=record_stop&app={$app}&name={$key}&token=" . getToken(60); } static function getButton($command, $live_transmition_id, $live_servers_id = 0, $iconsOnly = false, $label = "", $class = "", $tooltip = "") { if (!User::canStream()) { return ""; } global $global; $id = "getButton" . uniqid(); if (empty($live_servers_id)) { $live_servers_id = self::getLiveServersIdRequest(); } switch ($command) { case "record_start": $buttonClass = "btn btn-default btn-sm"; $iconClass = "fas fa-video"; if (empty($label)) { $label = __("Start Record"); } if (empty($tooltip)) { $tooltip = __("Start Record"); } break; case "record_stop": $buttonClass = "btn btn-default btn-sm"; $iconClass = "fas fa-video-slash"; if (empty($label)) { $label = __("Stop Record"); } if (empty($tooltip)) { $tooltip = __("Stop Record"); } break; case "drop_publisher": $buttonClass = "btn btn-default btn-sm"; $iconClass = "fas fa-wifi"; if (empty($label)) { $label = __("Disconnect Livestream"); } if (empty($tooltip)) { $tooltip = __("Disconnect Livestream"); } break; case "drop_publisher_reset_key": $buttonClass = "btn btn-default btn-sm"; $iconClass = "fas fa-key"; if (empty($label)) { $label = __("Disconnect Livestream"); } if (empty($tooltip)) { $tooltip = __("Disconnect Livestream") . __(" and also reset the stream name/key"); } break; default: return ''; } if ($iconsOnly) { $label = ""; } $html = ""; return $html; } static function getRecordControlls($live_transmition_id, $live_servers_id = 0, $iconsOnly = false) { if (!User::canStream()) { return ""; } $btn = "
"; $btn .= self::getButton("record_start", $live_transmition_id, $live_servers_id, $iconsOnly); $btn .= self::getButton("record_stop", $live_transmition_id, $live_servers_id, $iconsOnly); $btn .= "
"; return $btn; } static function getAllControlls($live_transmition_id, $live_servers_id = 0, $iconsOnly = false) { if (!User::canStream()) { return ""; } $btn = "
"; //$btn .= self::getButton("drop_publisher", $live_transmition_id, $live_servers_id); $btn .= self::getButton("drop_publisher_reset_key", $live_transmition_id, $live_servers_id, $iconsOnly); $btn .= self::getButton("record_start", $live_transmition_id, $live_servers_id, $iconsOnly); $btn .= self::getButton("record_stop", $live_transmition_id, $live_servers_id, $iconsOnly); $btn .= "
"; return $btn; } static function getRestreamer($live_servers_id = -1) { $obj = AVideoPlugin::getObjectData("Live"); if (!empty($obj->useLiveServers)) { if ($live_servers_id < 0) { $live_servers_id = self::getCurrentLiveServersId(); } $ls = new Live_servers($live_servers_id); if (!empty($ls->getRestreamerURL())) { return $ls->getRestreamerURL(); } } return $obj->restreamerURL; } static function getControl($live_servers_id = -1) { $obj = AVideoPlugin::getObjectData("Live"); if (!empty($obj->controlURL)) { if ($live_servers_id < 0) { $live_servers_id = self::getCurrentLiveServersId(); } $ls = new Live_servers($live_servers_id); if (!empty($ls->getControlURL())) { return $ls->getControlURL(); } } return $obj->controlURL; } static function getRTMPLink($users_id) { if (!User::isLogged() || ($users_id !== User::getId() && !User::isAdmin())) { return false; } $user = new User($users_id); $trasnmition = LiveTransmition::createTransmitionIfNeed($users_id); return self::getServer() . "?p=" . $user->getPassword() . "/" . $trasnmition['key']; } static function getPlayerServer() { $obj = AVideoPlugin::getObjectData("Live"); $url = $obj->playerServer; if (!empty($obj->useLiveServers)) { $ls = new Live_servers(self::getLiveServersIdRequest()); if (!empty($ls->getPlayerServer())) { $url = $ls->getPlayerServer(); } } $url = str_replace("encoder.gdrive.local", "192.168.1.18", $url); return $url; } static function getUseAadaptiveMode() { $obj = AVideoPlugin::getObjectData("Live"); if (!empty($obj->useLiveServers)) { $ls = new Live_servers(self::getCurrentLiveServersId()); return $ls->getUseAadaptiveMode(); } return $obj->useAadaptiveMode; } static function getRemoteFile() { $obj = AVideoPlugin::getObjectData("Live"); if (!empty($obj->useLiveServers)) { $ls = new Live_servers(self::getCurrentLiveServersId()); return $ls->getGetRemoteFile(); } return false; } static function getRemoteFileFromRTMPHost($rtmpHostURI) { $obj = AVideoPlugin::getObjectData("Live"); if (!empty($obj->useLiveServers)) { $live_servers_id = Live_servers::getServerIdFromRTMPHost($rtmpHostURI); if ($live_servers_id) { $ls = new Live_servers($live_servers_id); return $ls->getGetRemoteFile(); } } return false; } static function getLiveServersIdRequest() { if (empty($_REQUEST['live_servers_id'])) { return 0; } return intval($_REQUEST['live_servers_id']); } static function getM3U8File($uuid, $doNotProtect = false) { global $global; $o = AVideoPlugin::getObjectData("Live"); $playerServer = self::getPlayerServer(); $live_servers_id = self::getLiveServersIdRequest(); $liveServer = new Live_servers($live_servers_id); if ($liveServer->getStats_url()) { $o->protectLive = $liveServer->getProtectLive(); $o->useAadaptiveMode = $liveServer->getUseAadaptiveMode(); } $uuid = LiveTransmition::keyNameFix($uuid); if ($o->protectLive && empty($doNotProtect)) { return "{$global['webSiteRootURL']}plugin/Live/m3u8.php?live_servers_id={$live_servers_id}&uuid=" . encryptString($uuid); } else if ($o->useAadaptiveMode) { return $playerServer . "/{$uuid}.m3u8"; } else { return $playerServer . "/{$uuid}/index.m3u8"; } } public function getDisableGifThumbs() { $o = $this->getDataObject(); return $o->disableGifThumbs; } public function getStatsURL($live_servers_id = 0) { global $global; $o = $this->getDataObject(); if (!empty($live_servers_id)) { $liveServer = new Live_servers($live_servers_id); if ($liveServer->getStats_url()) { return $liveServer->getStats_url(); } } return $o->stats; } public function getChat($uuid) { global $global; //check if LiveChat Plugin is available $filename = $global['systemRootPath'] . 'plugin/LiveChat/LiveChat.php'; if (file_exists($filename)) { require_once $filename; LiveChat::includeChatPanel($uuid); } } function getStatsObject($live_servers_id = 0) { if (!function_exists('simplexml_load_file')) { _error_log("Live::getStatsObject: You need to install the simplexml_load_file function to be able to see the Live stats", AVideoLog::$ERROR); return false; } global $getStatsObject; if (!empty($getStatsObject[$live_servers_id])) { return $getStatsObject[$live_servers_id]; } $o = $this->getDataObject(); if ($o->doNotProcessNotifications) { $xml = new stdClass(); $xml->server = new stdClass(); $xml->server->application = array(); return $xml; } if (empty($o->requestStatsTimout)) { $o->requestStatsTimout = 2; } ini_set('allow_url_fopen ', 'ON'); $url = $this->getStatsURL($live_servers_id); if (!empty($_SESSION['getStatsObjectRequestStatsTimout'][$url])) { _error_log("Live::getStatsObject RTMP Server ($url) is NOT responding we will wait less from now on => live_servers_id = ($live_servers_id) "); // if the server already fail, do not wait mutch for it next time, just wait 0.5 seconds $o->requestStatsTimout = $_SESSION['getStatsObjectRequestStatsTimout'][$url]; } $data = $this->get_data($url, $o->requestStatsTimout); if (empty($data)) { _session_start(); if (empty($_SESSION['getStatsObjectRequestStatsTimout'])) { $_SESSION['getStatsObjectRequestStatsTimout'] = array(); } $_SESSION['getStatsObjectRequestStatsTimout'][$url] = $o->requestStatsTimout-1; if($_SESSION['getStatsObjectRequestStatsTimout'][$url]<1){ $_SESSION['getStatsObjectRequestStatsTimout'][$url] = 2; } _error_log("Live::getStatsObject RTMP Server ($url) is OFFLINE, timeout=({$o->requestStatsTimout}) we could not connect on it => live_servers_id = ($live_servers_id) ", AVideoLog::$ERROR); $data = 'The RTMP Server is Unavailable0'; } else { if (!empty($_SESSION['getStatsObjectRequestStatsTimout'][$url])) { _error_log("Live::getStatsObject RTMP Server ($url) is respond again => live_servers_id = ($live_servers_id) "); // the server respont again, wait the default time _session_start(); $_SESSION['getStatsObjectRequestStatsTimout'][$url] = 0; unset($_SESSION['getStatsObjectRequestStatsTimout'][$url]); } } $xml = simplexml_load_string($data); $getStatsObject[$live_servers_id] = $xml; return $xml; } function get_data($url, $timeout) { try { $content = url_get_contents($url, "", $timeout); return $content; } catch (Exception $exc) { _error_log($exc->getTraceAsString()); } return false; } public function getChartTabs() { return '
  • ' . __('Live videos') . '
  • '; } public function getChartContent() { global $global; include $global['systemRootPath'] . 'plugin/Live/report.php'; } static public function saveHistoryLog($key) { // get the latest history for this key $latest = LiveTransmitionHistory::getLatest($key); if (!empty($latest)) { LiveTransmitionHistoryLog::addLog($latest['id']); } } public function dataSetup() { $obj = $this->getDataObject(); if (!isLive() || $obj->disableDVR) { return ""; } return "liveui: true"; } static function stopLive($users_id) { if (!User::isAdmin() && User::getId() != $users_id) { return false; } $obj = AVideoPlugin::getObjectData("Live"); if (!empty($obj)) { $server = str_replace("stats", "", $obj->stats); $lt = new LiveTransmition(0); $lt->loadByUser($users_id); $key = $lt->getKey(); $appName = self::getApplicationName(); $url = "{$server}control/drop/publisher?app={$appName}&name=$key"; url_get_contents($url); $dir = $obj->hls_path . "/$key"; if (is_dir($dir)) { exec("rm -fR $dir"); rrmdir($dir); } } } // not implemented yet static function startRecording($users_id) { if (!User::isAdmin() && User::getId() != $users_id) { return false; } $obj = AVideoPlugin::getObjectData("Live"); if (!empty($obj)) { $server = str_replace("stats", "", $obj->stats); $lt = new LiveTransmition(0); $lt->loadByUser($users_id); $key = $lt->getKey(); $appName = self::getApplicationName(); $url = "{$server}control/record/start?app={$appName}&name=$key"; url_get_contents($url); } } static function getApplicationName() { $obj = AVideoPlugin::getObjectData('Live'); $parts = explode("/", $obj->playerServer); $live = end($parts); if (empty($live)) { $live = "live"; } return $live; } // not implemented yet static function stopRecording($users_id) { if (!User::isAdmin() && User::getId() != $users_id) { return false; } $obj = AVideoPlugin::getObjectData("Live"); if (!empty($obj)) { $server = str_replace("stats", "", $obj->stats); $lt = new LiveTransmition(0); $lt->loadByUser($users_id); $key = $lt->getKey(); $appName = self::getApplicationName(); $url = "{$server}control/record/stop?app={$appName}&name=$key"; url_get_contents($url); } } static function getLinkToLiveFromUsers_id($users_id) { $live_servers_id = self::getCurrentLiveServersId(); return self::getLinkToLiveFromUsers_idAndLiveServer($users_id, $live_servers_id); } static function getLinkToLiveFromUsers_idAndLiveServer($users_id, $live_servers_id) { if (empty($users_id)) { return false; } global $global; $user = new User($users_id); if (empty($user->getChannelName())) { return false; } return self::getLinkToLiveFromChannelNameAndLiveServer($user->getChannelName(), $live_servers_id); } static function getLinkToLiveFromChannelNameAndLiveServer($channelName, $live_servers_id) { global $global; $live_servers_id = intval($live_servers_id); $channelName = trim($channelName); if (empty($channelName)) { return false; } $playlists_id_live = ""; if (!empty($_REQUEST['playlists_id_live'])) { $playlists_id_live = "?playlists_id_live=" . $_REQUEST['playlists_id_live']; } //return "{$global['webSiteRootURL']}plugin/Live/?live_servers_id={$live_servers_id}&c=" . urlencode($channelName); return "{$global['webSiteRootURL']}live/{$live_servers_id}/" . urlencode($channelName) . $playlists_id_live; } static function getAvailableLiveServersId() { $ls = self::getAvailableLiveServer(); if (empty($ls)) { return 0; } else { return intval($ls->live_servers_id); } } static function getLastServersIdFromUser($users_id) { $last = LiveTransmitionHistory::getLatestFromUser($users_id); if (empty($last)) { return 0; } else { return intval($last['live_servers_id']); } } static function getLinkToLiveFromUsers_idWithLastServersId($users_id) { $live_servers_id = self::getLastServersIdFromUser($users_id); return self::getLinkToLiveFromUsers_idAndLiveServer($users_id, $live_servers_id); } static function getCurrentLiveServersId() { $live_servers_id = self::getLiveServersIdRequest(); if ($live_servers_id) { return $live_servers_id; } else { return self::getAvailableLiveServersId(); } } public function getVideosManagerListButtonTitle() { global $global; if (!User::isAdmin()) { return ""; } $btn = '
    '; return $btn; } public function getPluginMenu() { global $global; return ' ' . __('Edit Live Servers') . ''; } static function getStats($force_recreate=false) { global $getStatsLive, $_getStats, $getStatsObject; if(!empty($force_recreate)){ unset($getStatsLive); $_getStats = array(); $getStatsObject = array(); } if (isset($getStatsLive)) { return $getStatsLive; } $obj = AVideoPlugin::getObjectData("Live"); if (empty($obj->useLiveServers)) { $getStatsLive = self::_getStats(0); return $getStatsLive; } else if (!empty(Live::getLiveServersIdRequest())) { $ls = new Live_servers(Live::getLiveServersIdRequest()); if (!empty($ls->getPlayerServer())) { $server = self::_getStats($ls->getId()); $server->live_servers_id = $ls->getId(); $server->playerServer = $ls->getPlayerServer(); $getStatsLive = $server; return $server; } } $ls = Live_servers::getAllActive(); $liveServers = array(); $getLiveServersIdRequest = self::getLiveServersIdRequest(); foreach ($ls as $value) { $server = Live_servers::getStatsFromId($value['id']); if (!empty($server) && is_object($server)) { $server->live_servers_id = $value['id']; $server->playerServer = $value['playerServer']; foreach ($server->applications as $key => $app) { if(self::isAdaptive($app['key'])){ continue; } $_REQUEST['live_servers_id'] = $value['id']; if (empty($app['key'])) { $app['key'] = ""; } $server->applications[$key]['m3u8'] = self::getM3U8File($app['key']); $server->applications[$key]['isURL200'] = isURL200($server->applications[$key]['m3u8']); } $liveServers[] = $server; } else { _error_log("Live::getStats Live Server NOT found {$value['id']} " . json_encode($server) . " " . json_encode($value)); } } $_REQUEST['live_servers_id'] = $getLiveServersIdRequest; $getStatsLive = $liveServers; return $liveServers; } static function isAdaptive($key){ $parts = explode("_", $key); if(!empty($parts[1])){ $adaptive = array('hi', 'low', 'mid'); if(in_array($parts[1], $adaptive)){ return true; } } return false; } static function getAllServers() { $obj = AVideoPlugin::getObjectData("Live"); if (empty($obj->useLiveServers)) { return array("id" => 0, "name" => __("Default"), "status" => "a", "rtmp_server" => $obj->server, 'playerServer' => $obj->playerServer, "stats_url" => $obj->stats, "disableDVR" => $obj->disableDVR, "disableGifThumbs" => $obj->disableGifThumbs, "useAadaptiveMode" => $obj->useAadaptiveMode, "protectLive" => $obj->protectLive, "getRemoteFile" => ""); } else { return Live_servers::getAllActive(); } } static function getAvailableLiveServer() { global $_getAvailableLiveServer; if(isset($_getAvailableLiveServer)){ return $_getAvailableLiveServer; } // create 1 min cache $name = "Live::getAvailableLiveServer"; $return = ObjectYPT::getCache($name, 60); if (empty($return)) { $obj = AVideoPlugin::getObjectData("Live"); if (empty($obj->useLiveServers)) { $return = false; } else { $liveServers = self::getStats(); usort($liveServers, function($a, $b) { if ($a->countLiveStream == $b->countLiveStream) { $_getAvailableLiveServer = 0; return 0; } $_getAvailableLiveServer = ($a->countLiveStream < $b->countLiveStream) ? -1 : 1;; return $_getAvailableLiveServer; }); if (empty($liveServers[0])) { _error_log("Live::getAvailableLiveServer we could not get server status, try to uncheck useLiveServers parameter from the Live plugin"); $_getAvailableLiveServer = array(); return array(); } $return = $liveServers[0]; ObjectYPT::setCache($name, $return); } } $_getAvailableLiveServer = $return; return $return; } static function canSeeLiveFromLiveKey($key) { $lt = self::getLiveTransmitionObjectFromKey($key); if (empty($lt)) { return false; } return $lt->userCanSeeTransmition(); } static function isAPrivateLiveFromLiveKey($key) { $lt = self::getLiveTransmitionObjectFromKey($key); if (empty($lt)) { return false; } return $lt->isAPrivateLive(); } static function getTitleFromUsers_Id($users_id){ $lt = self::getLiveTransmitionObjectFromUsers_id($users_id); return $lt->getTitle(); } static function getLiveTransmitionObjectFromUsers_id($users_id) { $key = self::getLiveKey($users_id); return self::getLiveTransmitionObjectFromKey($key); } static function getLiveTransmitionObjectFromKey($key) { global $getLiveTransmitionObjectFromKey; if (empty($getLiveTransmitionObjectFromKey)) { $getLiveTransmitionObjectFromKey = array(); } $parts = explode("_", $key); if (empty($parts[0])) { return false; } if (!isset($getLiveTransmitionObjectFromKey[$parts[0]])) { $livet = LiveTransmition::keyExists($parts[0]); if (empty($livet)) { $getLiveTransmitionObjectFromKey[$parts[0]] = false; } else { $lt = new LiveTransmition($livet['id']); $getLiveTransmitionObjectFromKey[$parts[0]] = $lt; } } return $getLiveTransmitionObjectFromKey[$parts[0]]; } static function _getStats($live_servers_id = 0) { global $global, $_getStats; if (empty($_REQUEST['name'])) { //_error_log("Live::_getStats {$live_servers_id} GET " . json_encode($_GET)); //_error_log("Live::_getStats {$live_servers_id} POST " . json_encode($_POST)); //_error_log("Live::_getStats {$live_servers_id} REQUEST " . json_encode($_REQUEST)); $_REQUEST['name'] = "undefined"; } if (!empty($_getStats[$live_servers_id][$_REQUEST['name']]) && is_object($_getStats[$live_servers_id][$_REQUEST['name']])) { //_error_log("Live::_getStats cached result {$_REQUEST['name']} " . json_encode($_getStats[$live_servers_id][$_REQUEST['name']])); return $_getStats[$live_servers_id][$_REQUEST['name']]; } session_write_close(); $obj = new stdClass(); $obj->error = true; $obj->msg = "OFFLINE"; $obj->nclients = 0; $obj->applications = array(); $obj->hidden_applications = array(); $obj->name = $_REQUEST['name']; $liveUsersEnabled = AVideoPlugin::isEnabledByName("LiveUsers"); $p = AVideoPlugin::loadPlugin("Live"); $xml = $p->getStatsObject($live_servers_id); $xml = json_encode($xml); $xml = json_decode($xml); $stream = false; $lifeStream = array(); //$obj->server = $xml->server; if (!empty($xml->server->application) && !is_array($xml->server->application)) { $application = $xml->server->application; $xml->server->application = array(); $xml->server->application[] = $application; } foreach ($xml->server->application as $key => $application) { if (!empty($application->live->stream)) { if (empty($lifeStream)) { $lifeStream = array(); } $stream = $application->live->stream; if (empty($application->live->stream->name) && !empty($application->live->stream[0]->name)) { foreach ($application->live->stream as $stream) { if(Live::isAdaptive($stream->name)){ continue; } $lifeStream[] = $stream; } } else { if(Live::isAdaptive($stream->name)){ continue; } $lifeStream[] = $application->live->stream; } } } $obj->disableGif = $p->getDisableGifThumbs(); $obj->countLiveStream = count($lifeStream); foreach ($lifeStream as $value) { if (!empty($value->name)) { $row = LiveTransmition::keyExists($value->name); if (empty($row['users_id'])) { continue; } if (!empty($row) && $value->name === $obj->name) { $obj->msg = "ONLINE"; } $title = $row['title']; $u = new User($row['users_id']); $hiddenName = preg_replace('/^(.{5})/', '*****', $value->name); if (!self::canSeeLiveFromLiveKey($value->name)) { $obj->hidden_applications[] = "{$row['channelName']} ($hiddenName} is a private live"; if (!User::isAdmin()) { continue; } else { $title .= " (private live)"; } } else if (empty($row) || empty($row['public'])) { $obj->hidden_applications[] = "{$row['channelName']} ($hiddenName} is set to not be listed"; if (!User::isAdmin()) { continue; } else { $title .= " (set to not be listed)"; } } else if ($u->getStatus() !== 'a') { $obj->hidden_applications[] = "{$row['channelName']} {$hiddenName} the user is inactive"; if (!User::isAdmin()) { continue; } else { $title .= " (user is inactive)"; } } $users = false; if ($liveUsersEnabled) { $filename = $global['systemRootPath'] . 'plugin/LiveUsers/Objects/LiveOnlineUsers.php'; if (file_exists($filename)) { require_once $filename; $liveUsers = new LiveOnlineUsers(0); $users = $liveUsers->getUsersFromTransmitionKey($value->name, $live_servers_id); } } $userName = $u->getNameIdentificationBd(); $user = $u->getUser(); $channelName = $u->getChannelName(); $photo = $u->getPhotoDB(); $poster = $global['webSiteRootURL'] . $p->getPosterImage($row['users_id'], $live_servers_id); $playlists_id_live = 0; if (preg_match("/.*_([0-9]+)/", $value->name, $matches)) { if (!empty($matches[1])) { $_REQUEST['playlists_id_live'] = intval($matches[1]); $playlists_id_live = $_REQUEST['playlists_id_live']; $photo = PlayLists::getImage($_REQUEST['playlists_id_live']); $title = PlayLists::getNameOrSerieTitle($_REQUEST['playlists_id_live']); } } $link = Live::getLinkToLiveFromChannelNameAndLiveServer($u->getChannelName(), $live_servers_id); // this variable is to keep it compatible for Mobile app $UserPhoto = $photo; $key = LiveTransmition::keyNameFix($value->name); $m3u8 = self::getM3U8File($key); $obj->applications[] = array( "key" => $key, "isPrivate" => self::isAPrivateLiveFromLiveKey($value->name), "users" => $users, "name" => $userName, "user" => $user, "photo" => $photo, "UserPhoto" => $UserPhoto, "title" => $title, 'channelName' => $channelName, 'poster' => $poster, 'link' => addQueryStringParameter($link, 'embed', 1), 'href' => $link, 'playlists_id_live' => $playlists_id_live, 'm3u8' => $m3u8, 'isURL200' => isURL200($m3u8) ); if ($value->name === $obj->name) { $obj->error = property_exists($value, 'publishing') ? false : true; $obj->msg = (!$obj->error) ? "ONLINE" : "Waiting for Streamer"; $obj->stream = $value; $obj->nclients = intval($value->nclients); break; } } } $obj->error = false; $_getStats[$live_servers_id][$_REQUEST['name']] = $obj; //_error_log("Live::_getStats NON cached result {$_REQUEST['name']} " . json_encode($obj)); return $obj; } static function getImage($users_id, $live_servers_id, $playlists_id_live = 0) { $p = AVideoPlugin::loadPlugin("Live"); if (self::isLive($users_id)) { $url = $p->getLivePosterImage($users_id, $live_servers_id); $url = addQueryStringParameter($url, "playlists_id_live", $playlists_id_live); } else { - $file = self::getOfflineImage(false); + $url = self::getOfflineImage(false); } return $url; } static function isLive($users_id, $live_servers_id = 0, $force_recreate=false) { if(empty($users_id)){ return false; } $key = self::getLiveKey($users_id); return self::isLiveAndIsReadyFromKey($key, $live_servers_id, $force_recreate=false); } static function isLiveFromKey($key, $live_servers_id = 0, $force_recreate=false) { if(empty($key)){ return false; } $json = self::getStats($force_recreate); if (!empty($json) && is_object($json) && !empty($json->applications)) { foreach ($json->applications as $value) { if (preg_match("/{$key}.*/", $value['key'])) { if (empty($live_servers_id)) { return true; } else { if (intval(@$value['live_servers_id']) == $live_servers_id) { return true; } } } } } return false; } static function isLiveAndIsReadyFromKey($key, $live_servers_id = 0, $force_recreate=false) { $m3u8 = self::getM3U8File($key); $isLiveFromKey = self::isLiveFromKey($key, $live_servers_id, $force_recreate); $is200 = isURL200($m3u8); _error_log("isLiveFromKey: {$isLiveFromKey}"); _error_log("m3u8: {$m3u8}"); _error_log("is200: {$is200}"); return $isLiveFromKey && $is200; } static function getOnlineLivesFromUser($users_id) { $key = self::getLiveKey($users_id); $json = self::getStats(); $lives = array(); if (!empty($json) && is_object($json) && !empty($json->applications)) { foreach ($json->applications as $value) { if (preg_match("/{$key}.*/", $value['key'])) { $lives[] = $value; } } } return $lives; } static function keyIsFromPlaylist($key) { $parts = explode("_", $key); if (empty($parts[1])) { return false; } return array('key' => $parts[0], 'playlists_id' => $parts[1]); } static function getLiveKey($users_id) { $lt = new LiveTransmition(0); $lt->loadByUser($users_id); return $lt->getKey(); } public function getImageGif($users_id, $live_servers_id = 0, $playlists_id_live = 0) { global $global; if (empty($live_servers_id)) { $live_servers_id = self::getCurrentLiveServersId(); } $u = new User($users_id); $username = $u->getUser(); $file = "plugin/Live/getImage.php?live_servers_id={$live_servers_id}&u={$username}&format=gif"; $url = $global['webSiteRootURL'] . $file; $url = addQueryStringParameter($url, "playlists_id_live", $playlists_id_live); return $url; } public static function getPosterImage($users_id, $live_servers_id) { global $global; $file = self::_getPosterImage($users_id, $live_servers_id); if (!file_exists($global['systemRootPath'] . $file)) { $file = "plugin/Live/view/OnAir.jpg"; } return $file; } public function getLivePosterImage($users_id, $live_servers_id = 0) { global $global; return $global['webSiteRootURL'] . self::getLivePosterImageRelativePath($users_id, $live_servers_id); } public function getLivePosterImageRelativePath($users_id, $live_servers_id = 0) { global $global; if (empty($live_servers_id)) { $live_servers_id = self::getCurrentLiveServersId(); } if (self::isLiveThumbsDisabled()) { $file = self::_getPosterImage($users_id, $live_servers_id); if (!file_exists($global['systemRootPath'] . $file)) { $file = "plugin/Live/view/OnAir.jpg"; } } else { $u = new User($users_id); $username = $u->getUser(); $file = "plugin/Live/getImage.php?live_servers_id={$live_servers_id}&u={$username}&format=jpg"; } return $file; } public static function isLiveThumbsDisabled() { $obj = AVideoPlugin::getDataObject("Live"); if (!empty($obj->disableLiveThumbs)) { return true; } return false; } public function getPosterThumbsImage($users_id, $live_servers_id) { global $global; $file = self::_getPosterThumbsImage($users_id, $live_servers_id); if (!file_exists($global['systemRootPath'] . $file)) { $file = self::getOnAirImage(false); } return $file; } static function getOfflineImage($includeURL = true) { global $global; $img = "plugin/Live/view/Offline.jpg"; if ($includeURL) { $img = "{$global['webSiteRootURL']}{$img}"; } return $img; } static function getOnAirImage($includeURL = true) { global $global; $img = "plugin/Live/view/OnAir.jpg"; if ($includeURL) { $img = "{$global['webSiteRootURL']}{$img}"; } return $img; } public static function _getPosterImage($users_id, $live_servers_id) { $file = "videos/userPhoto/Live/user_{$users_id}_bg_{$live_servers_id}.jpg"; return $file; } public function _getPosterThumbsImage($users_id, $live_servers_id) { $file = "videos/userPhoto/Live/user_{$users_id}_thumbs_{$live_servers_id}.jpg"; return $file; } public static function on_publish($liveTransmitionHistory_id) { $obj = AVideoPlugin::getDataObject("Live"); if (empty($obj->disableRestream)) { self::restream($liveTransmitionHistory_id); } } public static function getRestreamObject($liveTransmitionHistory_id) { if (empty($liveTransmitionHistory_id)) { return false; } $lth = new LiveTransmitionHistory($liveTransmitionHistory_id); if (empty($lth->getKey())) { return false; } $_REQUEST['live_servers_id'] = $lth->getLive_servers_id(); $obj = new stdClass(); $obj->m3u8 = self::getM3U8File($lth->getKey(), true); $obj->restreamerURL = self::getRestreamer($lth->getLive_servers_id()); $obj->restreamsDestinations = array(); $obj->token = getToken(60); $obj->users_id = $lth->getUsers_id(); $rows = Live_restreams::getAllFromUser($lth->getUsers_id()); foreach ($rows as $value) { $value['stream_url'] = rtrim($value['stream_url'], "/") . '/'; $obj->restreamsDestinations[] = "{$value['stream_url']}{$value['stream_key']}"; } return $obj; } public static function restream($liveTransmitionHistory_id) { ignore_user_abort(true); ob_start(); header("Connection: close"); @header("Content-Length: " . ob_get_length()); ob_end_flush(); flush(); try { $obj = self::getRestreamObject($liveTransmitionHistory_id); if (empty($obj)) { return false; } $data_string = json_encode($obj); _error_log("Live:restream ({$obj->restreamerURL}) {$data_string}"); //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_URL, $obj->restreamerURL); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data_string)) ); $output = curl_exec($ch); curl_close($ch); return json_decode($output); } catch (Exception $exc) { _error_log("Live:restream " . $exc->getTraceAsString()); } return false; } public static function canStreamWithMeet() { if (!User::canStream()) { return false; } if (!User::canCreateMeet()) { return false; } $mobj = AVideoPlugin::getObjectDataIfEnabled("Meet"); if (empty($mobj)) { return false; } $obj = AVideoPlugin::getObjectDataIfEnabled("Live"); if (!empty($obj->disableMeetCamera)) { return false; } return true; } public function getUploadMenuButton() { global $global; $obj = $this->getDataObject(); if (!empty($obj->doNotShowGoLiveButton) || !User::canStream()) { return ''; } $buttonTitle = $this->getButtonTitle(); //include $global['systemRootPath'] . 'plugin/Live/getUploadMenuButton.php'; } public static function getAllVideos($status = "", $showOnlyLoggedUserVideos = false, $activeUsersOnly = true) { global $global, $config, $advancedCustom; if (AVideoPlugin::isEnabledByName("VideoTags")) { if (!empty($_GET['tags_id']) && empty($videosArrayId)) { TimeLogStart("video::getAllVideos::getAllVideosIdFromTagsId({$_GET['tags_id']})"); $videosArrayId = VideoTags::getAllVideosIdFromTagsId($_GET['tags_id']); TimeLogEnd("video::getAllVideos::getAllVideosIdFromTagsId({$_GET['tags_id']})", __LINE__); } } $status = str_replace("'", "", $status); $sql = "SELECT u.*, v.*, c.iconClass, c.name as category, c.clean_name as clean_category,c.description as category_description, v.created as videoCreation, v.modified as videoModified " . " FROM live_transmitions as v " . " LEFT JOIN categories c ON categories_id = c.id " . " LEFT JOIN users u ON v.users_id = u.id " . " WHERE 1=1 "; if ($showOnlyLoggedUserVideos === true && !Permissions::canModerateVideos()) { $uid = intval(User::getId()); $sql .= " AND v.users_id = '{$uid}'"; } elseif (!empty($showOnlyLoggedUserVideos)) { $uid = intval($showOnlyLoggedUserVideos); $sql .= " AND v.users_id = '{$uid}'"; } elseif (!empty($_GET['channelName'])) { $user = User::getChannelOwner($_GET['channelName']); $uid = intval($user['id']); $sql .= " AND v.users_id = '{$uid}' "; } if ($activeUsersOnly) { $sql .= " AND u.status = 'a' "; } if ($status == "publicOnly") { $sql .= " AND v.public = 1 "; } elseif (!empty($status)) { $sql .= " AND v.`public` = '{$status}'"; } if (!empty($_GET['catName'])) { $catName = $global['mysqli']->real_escape_string($_GET['catName']); $sql .= " AND (c.clean_name = '{$catName}' OR c.parentId IN (SELECT cs.id from categories cs where cs.clean_name = '{$catName}' ))"; } if (!empty($_GET['modified'])) { $_GET['modified'] = str_replace("'", "", $_GET['modified']); $sql .= " AND v.modified >= '{$_GET['modified']}'"; } $sql .= AVideoPlugin::getVideoWhereClause(); if (strpos(strtolower($sql), 'limit') === false) { if (!empty($_GET['limitOnceToOne'])) { $sql .= " LIMIT 1"; unset($_GET['limitOnceToOne']); }else{ $_REQUEST['rowCount'] = getRowCount(); if (!empty($_REQUEST['rowCount'])) { $sql .= " LIMIT {$_REQUEST['rowCount']}"; } else { _error_log("getAllVideos without limit " . json_encode(debug_backtrace())); if (empty($global['limitForUnlimitedVideos'])) { $global['limitForUnlimitedVideos'] = 100; } if ($global['limitForUnlimitedVideos'] > 0) { $sql .= " LIMIT {$global['limitForUnlimitedVideos']}"; } } } } //echo $sql;exit; //_error_log("getAllVideos($status, $showOnlyLoggedUserVideos , $ignoreGroup , ". json_encode($videosArrayId).")" . $sql); $res = sqlDAL::readSql($sql); $fullData = sqlDAL::fetchAllAssoc($res); sqlDAL::close($res); $videos = array(); if ($res != false) { foreach ($fullData as $row) { unset($row['password']); unset($row['recoverPass']); $row['live_servers_id'] = self::getLastServersIdFromUser($row['users_id']); if (empty($otherInfo)) { $otherInfo = array(); $otherInfo['category'] = xss_esc_back($row['category']); $otherInfo['groups'] = UserGroups::getVideoGroups($row['id']); //$otherInfo['title'] = UTF8encode($row['title']); $otherInfo['description'] = UTF8encode($row['description']); $otherInfo['descriptionHTML'] = Video::htmlDescription($otherInfo['description']); $otherInfo['filesize'] = 0; } foreach ($otherInfo as $key => $value) { $row[$key] = $value; } $row['rotation'] = 0; $row['filename'] = ''; $row['type'] = 'live'; $row['duration'] = ''; $row['isWatchLater'] = 0; $row['isFavorite'] = 0; $row['views_count'] = 0; $videos[] = $row; } //$videos = $res->fetch_all(MYSQLI_ASSOC); } else { $videos = false; die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error); } return $videos; } } diff --git a/plugin/Live/install/nginx.conf b/plugin/Live/install/nginx.conf index 65e12e3f8..a3633b98c 100644 --- a/plugin/Live/install/nginx.conf +++ b/plugin/Live/install/nginx.conf @@ -1,117 +1,118 @@ user www-data; worker_processes 1; error_log logs/error.log debug; events { worker_connections 1024; } rtmp { server { listen 1935; allow play all; #creates our "live" full-resolution HLS videostream from our incoming encoder stream and tells where to put the HLS video manifest and video fragments application live { allow play all; live on; hls on; hls_nested on; hls_path /HLS/live; hls_playlist_length 60m; hls_fragment 4s; on_publish http://localhost/AVideo/plugin/Live/on_publish.php; + on_publish_done http://localhost/AVideo/plugin/Live/on_publish_done.php; on_play http://localhost/AVideo/plugin/Live/on_play.php; on_record_done http://localhost/AVideo/plugin/Live/on_record_done.php; #exec ffmpeg -i rtmp://localhost/live/$name # -c:a aac -strict -2 -b:a 96k -c:v libx264 -vf scale=-2:240 -g 48 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 400k -maxrate 700k -bufsize 1200k -b:a 96k -r 20 -f hls -hls_time 6 -hls_list_size 0 -f flv rtmp://localhost/adaptive/$name_low # -c:a aac -strict -2 -b:a 128k -c:v libx264 -vf scale=-2:480 -g 48 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 1200k -maxrate 2100k -bufsize 2400k -b:a 128k -f hls -hls_time 6 -hls_list_size 0 -f flv rtmp://localhost/adaptive/$name_mid # -c:a aac -strict -2 -b:a 128k -c:v libx264 -vf scale=-2:720 -g 48 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 2400k -maxrate 4200k -bufsize 100000k -b:a 128k -f hls -hls_time 6 -hls_list_size 0 -f flv rtmp://localhost/adaptive/$name_hi; #recorder video{ # record all; # record_path /var/www/tmp; # record_notify on; # record_max_size 2048M; # record_suffix -%d-%b-%y-%T.flv; #} } #application adaptive { # live on; # hls on; # hls_path /HLS/live; # hls_nested on; # hls_playlist_length 10m; # allow play all; # allow publish 127.0.0.1; # deny publish all; # hls_variant _low BANDWIDTH=400000; # hls_variant _mid BANDWIDTH=2100000; # hls_variant _hi BANDWIDTH=4200000; #} } } http { include mime.types; default_type application/octet-stream; server { #listen 8443 ssl; #listen [::]:8443 ssl; #include /usr/local/nginx/snippets/self-signed.conf; #include /usr/local/nginx/snippets/ssl-params.conf; listen 8080; server_name localhost; #creates the http-location for our full-resolution (desktop) HLS stream - "http://my-ip/live/my-stream-key/index.m3u8" location /live { # Disable cache add_header 'Cache-Control' 'no-cache'; # CORS setup add_header 'Access-Control-Allow-Origin' '*' always; add_header 'Access-Control-Expose-Headers' 'Content-Length'; # allow CORS preflight requests if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Max-Age' 1728000; add_header 'Content-Type' 'text/plain charset=UTF-8'; add_header 'Content-Length' 0; return 204; } types { application/vnd.apple.mpegurl m3u8; } alias /HLS/live; } #allows us to see how stats on viewers on our Nginx site using a URL like: "http://my-ip/stats" #location /stats { # stub_status; #} location /stat { rtmp_stat all; rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { root html; } location /control { # replace this with the IP of your AVideo site allow localhost; deny all; rtmp_control all; } #allows us to host some webpages which can show our videos: "http://my-ip/my-page.html" location / { root html; index index.html index.htm; } #location ~ \.php$ { # include /etc/nginx/snippets/fastcgi-php.conf; # fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; #} } } diff --git a/plugin/Live/install/nginx.old.conf b/plugin/Live/install/nginx.old.conf deleted file mode 100644 index 5f24ca964..000000000 --- a/plugin/Live/install/nginx.old.conf +++ /dev/null @@ -1,45 +0,0 @@ -events { - worker_connections 1024; -} -http { - include mime.types; - default_type application/octet-stream; - sendfile on; - keepalive_timeout 65; - server { - listen 81; - server_name localhost; - - location / { - root html; - index index.html index.htm; - } - - location /stat { - rtmp_stat all; - rtmp_stat_stylesheet stat.xsl; - } - location /stat.xsl { - root html; - } - location /control { - rtmp_control all; - } - - } -} -rtmp { - server { - listen 1935; - chunk_size 4096; - - application live { - live on; - record off; - on_publish http://[AVideoURL]/plugin/Live/on_publish.php; - } - } -} - - - diff --git a/plugin/LiveLinks/LiveLinks.php b/plugin/LiveLinks/LiveLinks.php index 7baddc10b..aaccc2b08 100644 --- a/plugin/LiveLinks/LiveLinks.php +++ b/plugin/LiveLinks/LiveLinks.php @@ -1,373 +1,374 @@ isReadyLabel(array('Live')); $help = "
    Help"; return $desc.$help; } public function getName() { return "LiveLinks"; } public function getEmptyDataObject() { global $global; $obj = new stdClass(); $obj->onlyAdminCanAddLinks = true; $obj->buttonTitle = "Add a Live Link"; $obj->disableGifThumbs = false; $obj->disableLiveThumbs = false; $obj->doNotShowLiveLinksLabel = false; $obj->disableProxy = false; return $obj; } public function getUUID() { return "39d3b5fe-9702-4f1d-9ffd-fe1cd22a4dc7"; } public function getPluginVersion() { return "3.2"; } public function canAddLinks() { $obj = $this->getDataObject(); if (!User::isLogged()) { return false; } if ($obj->onlyAdminCanAddLinks && !User::isAdmin()) { return false; } return User::canStream(); } public function getHTMLMenuRight() { global $global; $obj = $this->getDataObject(); if (!$this->canAddLinks()) { return ''; } include $global['systemRootPath'] . 'plugin/LiveLinks/view/menuRight.php'; } static function getAllActive() { global $global; $sql = "SELECT * FROM LiveLinks WHERE status='a' AND start_date <= now() AND end_date >= now() ORDER BY start_date "; $res = $global['mysqli']->query($sql); $rows = array(); if ($res) { while ($row = $res->fetch_assoc()) { $rows[] = $row; } } else { die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error); } return $rows; } static function getImage($id) { global $global; return "{$global['webSiteRootURL']}plugin/LiveLinks/getImage.php?id={$id}&format=jpg"; } static function getImageGif($id) { global $global; return "{$global['webSiteRootURL']}plugin/LiveLinks/getImage.php?id={$id}&format=gif"; } /** * * @return type array(array("key"=>'live key', "users"=>false, "name"=>$userName, "user"=>$user, "photo"=>$photo, "UserPhoto"=>$UserPhoto, "title"=>'')); */ public function getLiveApplicationArray() { global $global; $obj = $this->getDataObject(); $filename = $global['systemRootPath'] . 'plugin/LiveLinks/view/menuItem.html'; $filenameExtra = $global['systemRootPath'] . 'plugin/LiveLinks/view/extraItem.html'; $filenameExtraVideoPage = $global['systemRootPath'] . 'plugin/LiveLinks/view/extraItemVideoPage.html'; $row = LiveLinks::getAllActive(); $array = array(); $search = array( '_unique_id_', '_user_photo_', '_title_', '_user_identification_', '_description_', '_link_', '_imgJPG_', '_imgGIF_', '_class_', '_total_on_live_links_id_' ); $content = file_get_contents($filename); $contentExtra = file_get_contents($filenameExtra); $contentExtraVideoPage = file_get_contents($filenameExtraVideoPage); $liveUsers = AVideoPlugin::isEnabledByName('LiveUsers'); foreach ($row as $value) { if($value['type']=='unlisted'){ continue; } if($value['type']=='logged_only'){ if(!User::isLogged()){ continue; } } $UserPhoto = User::getPhoto($value['users_id']); $name = User::getNameIdentificationById($value['users_id']); $replace = array( $value['id'], $UserPhoto, $value['title'], $name, str_replace('"', "", $value['description']), self::getLink($value['id']), '', empty($obj->disableGifThumbs)?(''):"", (isVideo())?"col-xs-6":"col-lg-2 col-md-4 col-sm-4 col-xs-6", ($liveUsers?getLiveUsersLabelLiveLinks($value['id']):'') ); $newContent = str_replace($search, $replace, $content); $newContentExtra = str_replace($search, $replace, $contentExtra); $newContentExtraVideoPage = str_replace($search, $replace, $contentExtraVideoPage); $array[] = array( "type" => "LiveLink", "html" => $newContent, "htmlExtra" => $newContentExtra, "htmlExtraVideoPage" => $newContentExtraVideoPage, "UserPhoto" => $UserPhoto, "title" => $value['title'], + "users_id" => $value['users_id'], "name" => $name, "poster" => self::getPosterToLiveFromId($value['id']), "link" => self::getLinkToLiveFromId($value['id'], true) ); } return $array; } public function updateScript() { global $global; if (AVideoPlugin::compareVersion($this->getName(), "2") < 0) { $sqls = file_get_contents($global['systemRootPath'] . 'plugin/LiveLinks/install/updateV2.0.sql'); $sqlParts = explode(";", $sqls); foreach ($sqlParts as $value) { sqlDal::writeSql(trim($value)); } } if (AVideoPlugin::compareVersion($this->getName(), "3.1") < 0) { $sqls = file_get_contents($global['systemRootPath'] . 'plugin/LiveLinks/install/updateV3.0.sql'); $sqlParts = explode(";", $sqls); foreach ($sqlParts as $value) { sqlDal::writeSql(trim($value)); } } return true; } public function getHeadCode() { global $global; $obj = $this->getDataObject(); // preload image $js = ""; $css = ''; if(!empty($obj->doNotShowLiveLinksLabel)){ $css .= ''; } return $js.$css; } public static function getLinkToLiveFromId($id, $embed=false){ return self::getLink($id, $embed); } public static function getLink($id, $embed=false){ global $global; //return "{$global['webSiteRootURL']}plugin/LiveLinks/view/Live.php?link={$id}".($embed?"&embed=1":""); $ll = new LiveLinksTable($id); if(!$embed){ return "{$global['webSiteRootURL']}liveLink/{$id}/". urlencode(cleanURLName($ll->getTitle())); }else{ return "{$global['webSiteRootURL']}liveLinkEmbed/{$id}/". urlencode(cleanURLName($ll->getTitle())); } } public function getPosterToLiveFromId($id){ global $global; return "{$global['webSiteRootURL']}plugin/LiveLinks/getImage.php?id={$id}&format=jpg"; } public static function isLiveThumbsDisabled(){ $obj = AVideoPlugin::getDataObject("LiveLinks"); if(!empty($obj->disableLiveThumbs)){ return true; } return false; } public function getPosterThumbsImage($users_id, $live_servers_id) { global $global; $file = Live::_getPosterThumbsImage($users_id, $live_servers_id); if (!file_exists($global['systemRootPath'] . $file)) { $file = "plugin/Live/view/OnAir.jpg"; } return $file; } public function getUploadMenuButton() { global $global; if (!$this->canAddLinks()) { return ''; } $obj = $this->getDataObject(); $buttonTitle = $obj->buttonTitle; //include $global['systemRootPath'] . 'plugin/LiveLinks/getUploadMenuButton.php'; } public static function getAllVideos($status = "", $showOnlyLoggedUserVideos = false, $activeUsersOnly = true) { global $global, $config, $advancedCustom; if (AVideoPlugin::isEnabledByName("VideoTags")) { if (!empty($_GET['tags_id']) && empty($videosArrayId)) { TimeLogStart("video::getAllVideos::getAllVideosIdFromTagsId({$_GET['tags_id']})"); $videosArrayId = VideoTags::getAllVideosIdFromTagsId($_GET['tags_id']); TimeLogEnd("video::getAllVideos::getAllVideosIdFromTagsId({$_GET['tags_id']})", __LINE__); } } $status = str_replace("'", "", $status); $sql = "SELECT u.*, v.*, c.iconClass, c.name as category, c.clean_name as clean_category,c.description as category_description, v.created as videoCreation, v.modified as videoModified " . " FROM LiveLinks as v " . " LEFT JOIN categories c ON categories_id = c.id " . " LEFT JOIN users u ON v.users_id = u.id " . " WHERE 1=1 "; if ($showOnlyLoggedUserVideos === true && !Permissions::canModerateVideos()) { $uid = intval(User::getId()); $sql .= " AND v.users_id = '{$uid}'"; } elseif (!empty($showOnlyLoggedUserVideos)) { $uid = intval($showOnlyLoggedUserVideos); $sql .= " AND v.users_id = '{$uid}'"; } elseif (!empty($_GET['channelName'])) { $user = User::getChannelOwner($_GET['channelName']); $uid = intval($user['id']); $sql .= " AND v.users_id = '{$uid}' "; } if ($activeUsersOnly) { $sql .= " AND u.status = 'a' "; } if ($status == "publicOnly") { $sql .= " AND v.`type` = 1 "; } elseif (!empty($status)) { $sql .= " AND v.`type` = '{$status}'"; } if (!empty($_GET['catName'])) { $catName = $global['mysqli']->real_escape_string($_GET['catName']); $sql .= " AND (c.clean_name = '{$catName}' OR c.parentId IN (SELECT cs.id from categories cs where cs.clean_name = '{$catName}' ))"; } if (!empty($_GET['modified'])) { $_GET['modified'] = str_replace("'", "", $_GET['modified']); $sql .= " AND v.modified >= '{$_GET['modified']}'"; } $sql .= AVideoPlugin::getVideoWhereClause(); if (strpos(strtolower($sql), 'limit') === false) { if (!empty($_GET['limitOnceToOne'])) { $sql .= " LIMIT 1"; unset($_GET['limitOnceToOne']); }else{ $_REQUEST['rowCount'] = getRowCount(); if (!empty($_REQUEST['rowCount'])) { $sql .= " LIMIT {$_REQUEST['rowCount']}"; } else { _error_log("getAllVideos without limit " . json_encode(debug_backtrace())); if (empty($global['limitForUnlimitedVideos'])) { $global['limitForUnlimitedVideos'] = 100; } if ($global['limitForUnlimitedVideos'] > 0) { $sql .= " LIMIT {$global['limitForUnlimitedVideos']}"; } } } } //echo $sql;exit; //_error_log("getAllVideos($status, $showOnlyLoggedUserVideos , $ignoreGroup , ". json_encode($videosArrayId).")" . $sql); $res = sqlDAL::readSql($sql); $fullData = sqlDAL::fetchAllAssoc($res); sqlDAL::close($res); $videos = array(); if ($res != false) { foreach ($fullData as $row) { unset($row['password']); unset($row['recoverPass']); if (empty($otherInfo)) { $otherInfo = array(); $otherInfo['category'] = xss_esc_back($row['category']); $otherInfo['groups'] = UserGroups::getVideoGroups($row['id']); //$otherInfo['title'] = UTF8encode($row['title']); $otherInfo['description'] = UTF8encode($row['description']); $otherInfo['descriptionHTML'] = Video::htmlDescription($otherInfo['description']); $otherInfo['filesize'] = 0; } foreach ($otherInfo as $key => $value) { $row[$key] = $value; } $row['rotation'] = 0; $row['filename'] = ''; $row['type'] = 'livelinks'; $row['duration'] = ''; $row['isWatchLater'] = 0; $row['isFavorite'] = 0; $row['views_count'] = 0; $videos[] = $row; } //$videos = $res->fetch_all(MYSQLI_ASSOC); } else { $videos = false; die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error); } return $videos; } } diff --git a/plugin/LoginTwitter/LoginTwitter.php b/plugin/LoginTwitter/LoginTwitter.php index 18d60c096..595975dda 100644 --- a/plugin/LoginTwitter/LoginTwitter.php +++ b/plugin/LoginTwitter/LoginTwitter.php @@ -1,52 +1,52 @@ getLogin(); $name = $obj->type; $str = "Login with {$name} OAuth Integration"; $str .= "
    Get {$name} ID and Key" - . "
    Valid OAuth redirect URIs: {$global['webSiteRootURL']}objects/login.json.php?type=$name" - . "
    For mobile a Valid OAuth redirect URIs: {$global['webSiteRootURL']}plugin/MobileManager/oauth2.php?type=$name"; + . "
    Valid OAuth redirect URIs: {$global['webSiteRootURL']}objects/login.json.php" + . "
    For mobile a Valid OAuth redirect URIs: {$global['webSiteRootURL']}plugin/MobileManager/oauth2.php"; return $str; } public function getName() { return "LoginTwitter"; } public function getUUID() { return "bc50f9c1-85d8-4898-8092-82ee69041b3f"; } public function getPluginVersion() { return "1.0"; } public function getEmptyDataObject() { global $global; $obj = new stdClass(); $obj->id = ""; $obj->key = ""; return $obj; } public function getLogin() { $obj = new stdClass(); $obj->class = "btn btn-info btn-block"; $obj->icon = "fab fa-twitter"; $obj->type = "Twitter"; $obj->linkToDevelopersPage = "https://apps.twitter.com/"; return $obj; } } diff --git a/plugin/YPTSocket/YPTSocket.php b/plugin/YPTSocket/YPTSocket.php index 120298623..8a6103d7d 100644 --- a/plugin/YPTSocket/YPTSocket.php +++ b/plugin/YPTSocket/YPTSocket.php @@ -1,161 +1,161 @@ "; - $desc .= "nohup php {$global['systemRootPath']}plugin/YPTSocket/server.php &"; + $desc .= "sudo nohup php {$global['systemRootPath']}plugin/YPTSocket/server.php &"; $help = "
    run this command start the server Help"; //$desc .= $this->isReadyLabel(array('YPTWallet')); return $desc.$help; } public function getName() { return "YPTSocket"; } public function getUUID() { return "YPTSocket-5ee8405eaaa16"; } public function getPluginVersion() { return "1.0"; } public static function getServerVersion() { return "2.2"; } public function updateScript() { global $global; /* if (AVideoPlugin::compareVersion($this->getName(), "2.0") < 0) { sqlDal::executeFile($global['systemRootPath'] . 'plugin/PayPerView/install/updateV2.0.sql'); } * */ return true; } public function getEmptyDataObject() { global $global; $obj = new stdClass(); $host = parse_url($global['webSiteRootURL'], PHP_URL_HOST); $server_crt_file = "/etc/letsencrypt/live/{$host}/fullchain.pem"; $server_key_file = "/etc/letsencrypt/live/{$host}/privkey.pem"; $host = parse_url($global['webSiteRootURL'], PHP_URL_HOST); $obj->port = "2053"; self::addDataObjectHelper('port', 'Server Port', 'You also MUST open this port on the firewall'); $obj->host = $host; self::addDataObjectHelper('host', 'Server host', 'If your site is HTTPS make sure this host also handle the SSL connection'); $obj->debugSocket = false; self::addDataObjectHelper('debugSocket', 'Show server debugger to admin', 'This will show a panel with some socket informations to the ADMIN user only'); $obj->debugAllUsersSocket = false; self::addDataObjectHelper('debugAllUsersSocket', 'Show server debugger to all', 'Same as above but will show the panel to all users'); $obj->server_crt_file = $server_crt_file; self::addDataObjectHelper('server_crt_file', 'SSL Certificate File', 'If your site use HTTPS, you MUST provide one'); $obj->server_key_file = $server_key_file; self::addDataObjectHelper('server_key_file', 'SSL Certificate Key File', 'If your site use HTTPS, you MUST provide one'); $obj->allow_self_signed = true; self::addDataObjectHelper('allow_self_signed', 'Allow self signed certs', 'Should be unchecked in production'); $obj->showTotalOnlineUsersPerVideo = true; self::addDataObjectHelper('showTotalOnlineUsersPerVideo', 'Show Total Online Users Per Video'); $obj->showTotalOnlineUsersPerLive = true; self::addDataObjectHelper('showTotalOnlineUsersPerLive', 'Show Total Online Users Per Live'); $obj->showTotalOnlineUsersPerLiveLink = true; self::addDataObjectHelper('showTotalOnlineUsersPerLiveLink', 'Show Total Online Users Per LiveLink'); return $obj; } public function getFooterCode() { self::getSocketJS(); } public static function getSocketJS() { global $global; include $global['systemRootPath'] . 'plugin/YPTSocket/footer.php'; } public static function send($msg, $callbackJSFunction = "", $users_id = "", $send_to_uri_pattern = "") { global $global, $SocketSendObj, $SocketSendUsers_id, $SocketSendResponseObj, $SocketURL; if(!is_string($msg)){ $msg = json_encode($msg); } $SocketSendUsers_id = $users_id; if(!is_array($SocketSendUsers_id)){ $SocketSendUsers_id = array($SocketSendUsers_id); } $SocketSendObj = new stdClass(); $SocketSendObj->webSocketToken = getEncryptedInfo(0,$send_to_uri_pattern); $SocketSendObj->msg = $msg; $SocketSendObj->json = json_decode($msg); $SocketSendObj->callback = $callbackJSFunction; $SocketSendResponseObj = new stdClass(); $SocketSendResponseObj->error = true; $SocketSendResponseObj->msg = ""; $SocketSendResponseObj->msgObj = $SocketSendObj; $SocketSendResponseObj->callbackJSFunction = $callbackJSFunction; require_once $global['systemRootPath'] . 'objects/autoload.php'; $SocketURL = self::getWebSocketURL(true); _error_log("Socket Send: {$SocketURL}"); \Ratchet\Client\connect($SocketURL)->then(function($conn) { global $SocketSendObj, $SocketSendUsers_id, $SocketSendResponseObj; $conn->on('message', function($msg) use ($conn) { //echo "Received: {$msg}\n"; //$conn->close(); $SocketSendResponseObj->error = false; }); foreach ($SocketSendUsers_id as $users_id) { $SocketSendObj->to_users_id = $users_id; $conn->send(json_encode($SocketSendObj)); } $conn->close(); //$SocketSendResponseObj->error = false; }, function ($e) { global $SocketURL; _error_log("Could not connect: {$e->getMessage()} {$SocketURL}", AVideoLog::$ERROR); }); return $SocketSendResponseObj; } public static function getWebSocketURL($isCommandLine=false) { global $global; $socketobj = AVideoPlugin::getDataObject("YPTSocket"); $address = $socketobj->host; $port = $socketobj->port; $protocol = "ws"; $scheme = parse_url($global['webSiteRootURL'], PHP_URL_SCHEME); if(strtolower($scheme)==='https'){ $protocol = "wss"; } return "{$protocol}://{$address}:{$port}?webSocketToken=".getEncryptedInfo(0)."&isCommandLine=".intval($isCommandLine); } } diff --git a/plugin/YPTSocket/server.php b/plugin/YPTSocket/server.php index 532e5947d..1d3065633 100644 --- a/plugin/YPTSocket/server.php +++ b/plugin/YPTSocket/server.php @@ -1,73 +1,80 @@ serverVersion = YPTSocket::getServerVersion(); ob_end_flush(); _mysql_close(); session_write_close(); $SocketDataObj->port = intval($SocketDataObj->port); _error_log("Starting Socket server at port {$SocketDataObj->port}"); killProcessOnPort(); $scheme = parse_url($global['webSiteRootURL'], PHP_URL_SCHEME); echo "Starting AVideo Socket server version {$SocketDataObj->serverVersion} on port {$SocketDataObj->port}".PHP_EOL; if(strtolower($scheme)!=='https'){ echo "Your socket server does NOT use a secure connection".PHP_EOL; $server = IoServer::factory( new HttpServer( new WsServer( new Message() ) ), $SocketDataObj->port ); $server->run(); } else { + if(!file_exists($SocketDataObj->server_crt_file) || !is_readable($SocketDataObj->server_crt_file)){ + echo "SSL ERROR, we could not access the CRT file {$SocketDataObj->server_crt_file}, try to run this command as root or use sudo ".PHP_EOL; + } + if(!file_exists($SocketDataObj->server_key_file) || !is_readable($SocketDataObj->server_key_file)){ + echo "SSL ERROR, we could not access the KEY file {$SocketDataObj->server_key_file}, try to run this command as root or use sudo ".PHP_EOL; + } + echo "Your socket server uses a secure connection".PHP_EOL; $parameters = [ 'local_cert' => $SocketDataObj->server_crt_file, 'local_pk' => $SocketDataObj->server_key_file, 'allow_self_signed' => $SocketDataObj->allow_self_signed, // Allow self signed certs (should be false in production) 'verify_peer' => false, 'verify_peer_name'=>false, 'security_level'=>0 ]; foreach ($parameters as $key => $value) { echo "Parameter [{$key}]: $value ".PHP_EOL; } $loop = React\EventLoop\Factory::create(); // Set up our WebSocket server for clients wanting real-time updates $webSock = new React\Socket\Server('0.0.0.0:' . $SocketDataObj->port, $loop); $webSock = new React\Socket\SecureServer($webSock, $loop, $parameters); $webServer = new Ratchet\Server\IoServer( new HttpServer( new WsServer( new Message() ) ), $webSock ); //$socket = new Reactor($webServer->loop); //$socket->listen(8082, '0.0.0.0'); //Port 2 //$socket->on('connection', [$webServer, 'handleConnect']); //$webServer->run(); $loop->run(); } \ No newline at end of file diff --git a/view/include/navbar.php b/view/include/navbar.php index d97943deb..420c6c16c 100644 --- a/view/include/navbar.php +++ b/view/include/navbar.php @@ -1,1394 +1,1408 @@ " class="btn btn-default" style="position: absolute; right: 10px; top: 5px;"> body{padding-top:0;}'; } echo ''; return ''; } if (!empty($advancedCustomUser->keepViewerOnChannel)) { if (!empty($_GET['channelName'])) { _session_start(); $_SESSION['channelName'] = $_GET['channelName']; } if (!empty($_GET['leaveChannel'])) { _session_start(); unset($_SESSION['channelName']); } } session_write_close(); global $includeDefaultNavBar, $global, $config, $advancedCustom, $advancedCustomUser; if (!isset($global['systemRootPath'])) { require_once '../videos/configuration.php'; } require_once $global['systemRootPath'] . 'objects/user.php'; require_once $global['systemRootPath'] . 'objects/category.php'; $_GET['parentsOnly'] = "1"; if (empty($_SESSION['language'])) { $lang = 'us'; } else { $lang = $_SESSION['language']; } $thisScriptFile = pathinfo($_SERVER["SCRIPT_FILENAME"]); if (empty($sidebarStyle)) { $sidebarStyle = "display: none;"; } $includeDefaultNavBar = true; AVideoPlugin::navBar(); if (!$includeDefaultNavBar) { return false; } ?> userMustBeLoggedIn) && !empty($advancedCustomUser->userMustBeLoggedInCloseButtonURL)) { ?> userMustBeLoggedIn) && empty($advancedCustom->disableNavbar)) || $thisScriptFile["basename"] === "signUp.php" || $thisScriptFile["basename"] === "userRecoverPass.php") || User::isLogged()) { $updateFiles = getUpdatesFilesArray(); ?> underMenuBarHTMLCode->value)) { echo $advancedCustom->underMenuBarHTMLCode->value; } } else if ($thisScriptFile["basename"] !== 'user.php' && empty($advancedCustom->disableNavbar)) { } unset($_GET['parentsOnly']); ?> diff --git a/view/listCategories.php b/view/listCategories.php new file mode 100644 index 000000000..5d581c9ee --- /dev/null +++ b/view/listCategories.php @@ -0,0 +1,177 @@ + + + + + + + + + +
    + + +
    +
    + 1 {$value['name']}"); + continue; + } + if ($advancedCustom->ShowAllVideosOnCategory) { + $total = $value['fullTotal']; + } else { + $total = $value['total']; + } + if (empty($total)) { + //var_dump("
    2 {$value['name']}"); + continue; + } + + if(!empty($value['fullTotal_videos'])){ + $video = Category::getLatestVideoFromCategory($value['id'], true, true); + $images = Video::getImageFromID($video['id']); + $image = $images->poster; + }else + if(!empty($value['fullTotal_lives'])){ + $live = Category::getLatestLiveFromCategory($value['id'], true, true); + $image = Live::getImage($live['users_id'], $live['live_servers_id']); + }else + if(!empty($value['fullTotal_livelinks'])){ + $liveLinks = Category::getLatestLiveLinksFromCategory($value['id'], true, true); + $image = LiveLinks::getImage($liveLinks['id']); + } + + $totalVideosOnChilds = Category::getTotalFromChildCategory($value['id']); + $childs = Category::getChildCategories($value['id']); + $photo = Category::getCategoryPhotoPath($value['id']); + $photoBg = Category::getCategoryBackgroundPath($value['id']); + $link = $global['webSiteRootURL'] . 'cat/' . $value['clean_name']; + $imageNotFound = preg_match('/notfound/i', $image); + $photoNotFound = preg_match('/notfound/i', $photo['url']); + $icon = ' ' ; + if (!$imageNotFound) { + ?> + + + + + +
    +
    +
    + +
    + +
    + +
    +
    +
    +
    + +
    +
    + + + + + + + + + + + + +
    + + +
    +
    +
    +
    +
    +
    +
    +
    + " value="" id="playFormInput" /> + + + +
    +
    +
    +
    +
    +
    +
    +
    + + + +